How to put three coordinates in an element of a matrix?

2 views (last 30 days)
What I'm trying to do is to put the coordinates of velocity vectors into the elements of a 2 dimensional matrix. (That is, I have to store velocity data (3x1 vector) for a rectangular cross section, which is represented by a two dimensional matrix.) After I filled it with velocity data I need to be able to access its elements with for loops.
Any ideas how to do it? Velocity_matrix(i,j) = [Vx Vy Vz] obviously does not work.
I would like to be able to access the elements with something like: for i=1:N for j=1:M W=Velocity_matrix(i,j); ... end end
Thank you for your answers in advance.

Accepted Answer

Walter Roberson
Walter Roberson on 28 Feb 2012
Cell arrays
Velocity_matrix{i,j} = [Vx Vy Vz];
and access like
for i=1:N
for j=1:M
W = Velocity_matrix{i,j};
...
end
end
Notice the curly brackets.

More Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!