How to assign elements in a matrix in another matrix with order not in sequence?
3 次查看(过去 30 天)
显示 更早的评论
I am trying to substitute the elements in matrix K to element K1 such that the matrix K has 10th, 11th,12th,7th, 8th and 9th elements in rows and column. How to assign this matrix in matrix K1 in it's own order???
0 个评论
回答(1 个)
Fangjun Jiang
2018-7-20
Not sure how you want to assign between K and K1, but here is an example, just specify the row and column number
>> A=magic(5)
A =
17 24 1 8 15
23 5 7 14 16
4 6 13 20 22
10 12 19 21 3
11 18 25 2 9
>> B=A([4,3,2],[2,5,3])
B =
12 3 19
6 22 13
5 16 7
2 个评论
Stephen23
2018-7-20
Thanks for your answer, but this is not what I mean. I am actually working to substitute the elements of matrix K in matrix K1 such that the (7,7) element on matrix K1 is V as shown in figure. Similarly, element on Matrix K1 (9,10) is IJ.
If you got what I mean, please help me.
Fangjun Jiang
2018-7-21
okay, follow my above example
A([4,3,2],[2,5,3])=B+100
So I think what you need is
K1([10 11 12 7 8 0],[10 11 12 7 8 9])=K
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!