Error using + Matrix dimensions must agree.

조회 수: 7 (최근 30일)
Gonçalo Cordeiro
Gonçalo Cordeiro 2018년 6월 4일
답변: Walter Roberson 2018년 6월 4일
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일
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