Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

How to do this pre-allocation without loop

조회 수: 3 (최근 30일)
ML
ML 2017년 2월 8일
마감: MATLAB Answer Bot 2021년 8월 20일
how to write the following pre-allocation without for-loop? i.e. using one line code?
for i = 1:size (Samples, 2)
for j =1:size(Samples{i},1)
A{i}(j,500) = 0;
end
end

답변 (1개)

KSSV
KSSV 2017년 2월 8일
A = cell(size(Samples,2),1) ;
for i = 1:size (Samples, 2)
for j =1:size(Samples{i},1)
A{i}(j,500) = 0;
end
end
  댓글 수: 3
KSSV
KSSV 2017년 2월 8일
Did you run it? If it throws any error, show the error. How you expect to give correct one with out knowing what is Samples size and it's class?
ML
ML 2017년 2월 8일
편집: ML 2017년 2월 8일
If you read the question, I asked without loop. Your solution still contains the for loop which I wrote above.
You only added a line to that which preallocates the cells.

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by