how to declare array of variable size

26 views (last 30 days)
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.

Accepted Answer

Oleg Komarov
Oleg Komarov on 28 Apr 2011
for i = 1:63
myArray{i} = zeros(a,b);
end
  2 Comments
Mohammad Golam Kibria
Mohammad Golam Kibria on 28 Apr 2011
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 on 28 Apr 2011
Preallocate before the loop:
myArray = cell(61,1);

Sign in to comment.

More Answers (0)

Categories

Find more on Operators and Elementary Operations in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!