Create a matrix from another matrix
1 view (last 30 days)
Show older comments
Giannakis Stoukas
on 4 May 2015
I have a matrix A=[ 5 6 4; 1 2 8; 9 7 11] and two arrays that have the coordinates x,y of every variable of the matrix A.I want to create two matrixes.The first one will have instead the variables of matrix A,the x coordinate and the other one matrix the y.For example the matrix X will have X=[x(5) x(6) x(4); x(1) x(2) x(8); x(9) x(7) x(11)]. Can i do it with one command.At my problems i have much bigger matrixes and i cant write it one by one.
0 Comments
Accepted Answer
Titus Edelhofer
on 4 May 2015
Hi Giannakis,
I guess just by using A as index:
A=[ 5 6 4; 1 2 8; 9 7 11];
x = 1:2:21
x =
1 3 5 7 9 11 13 15 17 19 21
x(A)
ans =
9 11 7
1 3 15
17 13 21
Titus
More Answers (0)
See Also
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!