필터 지우기
필터 지우기

how to create character matrix help

조회 수: 3 (최근 30일)
Huseyin
Huseyin 2014년 3월 3일
답변: per isakson 2014년 3월 3일
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

채택된 답변

per isakson
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개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by