pre allocating vector for loop

1 view (last 30 days)
Oday Shahadh
Oday Shahadh on 12 Jun 2020
Commented: Oday Shahadh on 12 Jun 2020
Can any one tell how to pre allocate c1?
thanks
for ii = 1:length(a11);
c1=cross(L1(1,:),a11(ii,:));
end

Accepted Answer

madhan ravi
madhan ravi on 12 Jun 2020
c1 = cell(numel(a11),1); % before loop use numel instead of length
c1{ii} = ... inside loop
  5 Comments
Oday Shahadh
Oday Shahadh on 12 Jun 2020
Then Madhani how can I switch all these cell arrays to ( n,3) matrix

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!