I'd like to create an array from elements in an 3D-matrix using z-coordinates stored in an another array. The simplest way would be:
X=2;
Y=3;
lastZ=10000000
for i=1:lastZ
new_array=matrix(X,Y,Z(i));
end
But I'm looking for a "vectorized" way using only matrices instead of for-loop. I've tried the following code but I get an error message "Subscript indices must either be real positive integers or logicals":
new_array=matrix(X,Y,Z);
I understand that Z is an array and cannot be put with X and Y which are integers. Is there a better way to create such array in one-liner code?