how to declare array of variable size

조회 수: 6 (최근 30일)
Mohammad Golam Kibria
Mohammad Golam Kibria 2011년 4월 28일
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
Mohammad Golam Kibria 2011년 4월 28일
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에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by