how to create character matrix help
조회 수: 3 (최근 30일)
이전 댓글 표시
Hi, I created a function called 'myfunction' and lets say the possible outputs of that functions are 'a','b','c' or 'ab'. Then I call this function for another process in a for loop. The code is;
a=0;
for k=1:4
liste(1+a,:)=myfunction(process);
a=a+1;
end
The answer must be 'a', 'b', 'c', 'ab' but the answer of this code is just 'a','b','c' and it stops and gives me an error about dimensions. I think the problem occurs because 'ab' is formed of 2 characters. How can I fix that??
Thanks
댓글 수: 0
채택된 답변
per isakson
2014년 3월 3일
liste = cell(4,1);
...
liste{1+a,1} = myfunction( process);
...
liste = char(liste);
or initialize
liste = repmat( ' ', [4,2] );
and fill in the output of myfunction (faster but a little bit more tricky )
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!