Error using + Matrix dimensions must agree.

7 次查看(过去 30 天)
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 个评论
Shrestha Kumar
Shrestha Kumar 2018-6-4
What do you want to do with this code? You want to concatenate each row of the matrix to results??

请先登录,再进行评论。

采纳的回答

Walter Roberson
Walter Roberson 2018-6-4
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 个)

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by