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

2 Ansichten (letzte 30 Tage)
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.

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 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.

Weitere Antworten (0)

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by