Is there another way to write test{1,1:10}=' ' ?

조회 수: 3 (최근 30일)
Megna Hari
Megna Hari 2014년 8월 19일
답변: Jan 2014년 8월 20일
Because obviously test{1,1:10}=' ' doesn't work:
"The right hand side of this assignment has too few values to satisfy the left hand side."
I had previously done test=cell(1,10) but ideally I want some sort of blank value in there that's not [] so when I later do a char() on each entry in the cell it won't complain that it can't do it.
  댓글 수: 1
Megna Hari
Megna Hari 2014년 8월 19일
Also, I dont want a for loop like this:
for i=1:10
test{1,i}='';
end
because it takes too long and this is going to be in a function that gets called approximately 1,870,000 times using cellfun.

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

채택된 답변

the cyclist
the cyclist 2014년 8월 19일
test(1,1:10) = {' '}
  댓글 수: 1
Megna Hari
Megna Hari 2014년 8월 19일
Thank you! That's exactly what I want :)

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

추가 답변 (1개)

Jan
Jan 2014년 8월 20일
Or shorter, if all elements are wanted:
test = cell(1,10);
test(:) = {' '};
Or:
test = repmat({' '}, 1, 10);

카테고리

Help CenterFile Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by