Question about a matlab matrix

56 Views Asked by At

To explain my problem I goint to show a little example.

I have a matrix K

$K=\begin{pmatrix}k_{11}&k_{12}&k_{13}\\ k_{21}&k_{22}&k_{23}\\ k_{31}&k_{32}&k_{33}\end{pmatrix}\in\mathbb{R}^{3\times 3}$

and a big matrix $A$, for example $A\in \mathbb{R}^{10\times 10}$.

I want put the matrix $K$ in $A$ using the position vector [2 7 9] as follow:

$A(2,2)=k_{11}$, $A(2,7)=k_{12}$, $A(2,9)=k_{13}$

$A(7,2)=k_{21}$, $A(7,7)=k_{22}$, $A(7,9)=k_{23}$

$A(9,2)=k_{31}$, $A(9,7)=k_{32}$, $A(9,9)=k_{33}$

Obviously, I can use a for cycle, but how can do this eficiently on matlab?

Thanks!

1

There are 1 best solutions below

0
On BEST ANSWER

I think something along these lines could work:

$$A([2,7,9],[2,7,9])=K$$

However, I do not have matlab on this machine so I can not test this. Let me know if this works.