Error using + Matrix dimensions must agree.

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??
Gonçalo Cordeiro
Gonçalo Cordeiro 2018 年 6 月 4 日
yes i want this

サインインしてコメントする。

 採用された回答

Walter Roberson
Walter Roberson 2018 年 6 月 4 日

0 投票

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 件)

カテゴリ

ヘルプ センター および File ExchangeMatrices and Arrays についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by