Filter löschen
Filter löschen

Create a matrix from another matrix

1 Ansicht (letzte 30 Tage)
Giannakis Stoukas
Giannakis Stoukas am 4 Mai 2015
Bearbeitet: Stephen23 am 4 Mai 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.

Akzeptierte Antwort

Titus Edelhofer
Titus Edelhofer am 4 Mai 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

Weitere Antworten (0)

Kategorien

Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by