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

2 visualizaciones (últimos 30 días)
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.

Respuesta aceptada

Walter Roberson
Walter Roberson el 28 de Feb. de 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.

Más respuestas (0)

Categorías

Más información sobre Logical en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by