How do I work with a two dimensional array with for loops in MATLAB?
24 次查看(过去 30 天)
显示 更早的评论
How can I do two dimensions array using a FOR loop? Example:
P = {k,l,m,n};
L = 4;
for i=1:L
New(i) = P(i);
end
I don't know how can i do write that result was array in two dimension: New = {k,l,m,n;k,l,m,n;k,l,m,n;k,l,m,n};
0 个评论
采纳的回答
更多回答(1 个)
Sean de Wolski
2011-1-24
Best way would be:
New = repmat(P,4,1);
You should also read up on indexing cell arrays.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!