How to put three coordinates in an element of a matrix?
2 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
采纳的回答
Walter Roberson
2012-2-28
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.
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!