Matlab Help-changing elements in a matrix
I have a matrix consisting of 20 rows and 100 columns. Each element in the matrix is a number between 1 and 10.
I also have 10 predefined values, x1 to x10.
I want to change each element in the matrix so that 1 changes to the value x1, 2 changes to the value x2 and so on.
Any help would be greatly appreciated.
I also have 10 predefined values, x1 to x10.
I want to change each element in the matrix so that 1 changes to the value x1, 2 changes to the value x2 and so on.
Any help would be greatly appreciated.
0
Comments
Then if you create a new matrix, say Z and let that be equal to X(Y), it will populate the matrix using the values defined in X by the index numbers from Y.
X=[x1, x2, x3, x4, x5, x6, x7, x8, x9, x10];
Z=X(Y);
Z should be the matrix you want.
For example.
x1=10;
x2=20;
X = [x1 x2]; % X = [10 20];
Y = [1 1;2 2; 1 2];
Z=X(Y);
This will give
Z = [10 10; 20 20; 10 20];
NERD
also i like butts.
Z = A.*A;