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
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
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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!