How to preallocate 3 D matrix?

조회 수: 60 (최근 30일)
reshdev
reshdev 2014년 9월 6일
댓글: Yu Jiang 2014년 9월 6일
Hello,
Suppose output(:,:) is matrix with 5 rows and 10 columns.
u is from 1 to n. So, i will have n different output(:,:) matrix's which i am saving in outp(:,:,u).
for u= 1:n
outp(:,:,u) = output(:,:);
end
then how can i pre allocate outp(:,:,u) with zeros so that i can increase speed.
will it be outp(:,:,u)= zeros(5*n,10)?
Thank You

채택된 답변

Yu Jiang
Yu Jiang 2014년 9월 6일
편집: Yu Jiang 2014년 9월 6일
outp(:,:,u)= zeros(5, 10, n)
  댓글 수: 2
Guillaume
Guillaume 2014년 9월 6일
Or even simpler:
outp = zeros(5, 10, n);
What you wrote works (if outp didn't exist), it's very confusing.
Yu Jiang
Yu Jiang 2014년 9월 6일
Guillaume
Your version is much better :)
-Yu

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by