Azzera filtri
Azzera filtri

how to create character matrix help

3 visualizzazioni (ultimi 30 giorni)
Huseyin
Huseyin il 3 Mar 2014
Risposto: per isakson il 3 Mar 2014
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

Risposta accettata

per isakson
per isakson il 3 Mar 2014
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 )

Più risposte (0)

Categorie

Scopri di più su Multidimensional Arrays in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by