Error using + Matrix dimensions must agree.
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Gonçalo Cordeiro
le 4 Juin 2018
Réponse apportée : Walter Roberson
le 4 Juin 2018
this is my code:
results = '';
for i = 1 : 1 : length(BBArray)
results = results + sprintf('%.0f\t' , BBArray(i, :))+'\n';
results + sprintf('%.0f\t' , BBArray(i, :))+'\n';
end
results;
how can i improve?
2 commentaires
Shrestha Kumar
le 4 Juin 2018
What do you want to do with this code? You want to concatenate each row of the matrix to results??
Réponse acceptée
Walter Roberson
le 4 Juin 2018
You cannot use + to concatenate character vectors.
If you are using R2017a or later, you could change the initial
results = '';
to
results = "";
and that would have you working with string objects instead of character vectors, which would support using + for concatenation.
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Creating and Concatenating Matrices 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!