how to declare array of variable size

26 次查看(过去 30 天)
Hi,
I need an array of variable size. for example
for i: 1:63 myArray(i) = zeros(a,b); end
where a,b are changing its value in every loop;
can any one suggest me how to declare that type of array.

采纳的回答

Oleg Komarov
Oleg Komarov 2011-4-28
for i = 1:63
myArray{i} = zeros(a,b);
end
  2 个评论
Mohammad Golam Kibria
It works but gives a warning. How to remove that warning. warning as follows :
The variable appears to be changed size on every loop iteration. consider preallocating for speed.
Oleg Komarov
Oleg Komarov 2011-4-28
Preallocate before the loop:
myArray = cell(61,1);

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Operators and Elementary Operations 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by