how to create character matrix help
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Huseyin
le 3 Mar 2014
Réponse apportée : per isakson
le 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
0 commentaires
Réponse acceptée
per isakson
le 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 )
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Multidimensional Arrays dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!