Horzcat error with num2str in disp function.
6 ビュー (過去 30 日間)
古いコメントを表示
When I run the following script:
A = [5,6,7;8,9,10;11,12,13];
disp(['The values in A are' num2str(A) '.'])
I get the following error message:
Error using horzcat
Dimensions of matrices being concatenated are not consistent.
Why?
0 件のコメント
回答 (2 件)
dpb
2015 年 2 月 10 日
Because A is 3x3 whereas the string is 1xlength(). Use
disp(['The values in A are' num2str(A(:).') '.'])
0 件のコメント
Star Strider
2015 年 2 月 10 日
Another option:
A = [5,6,7;8,9,10;11,12,13];
disp('The values in A are ')
disp(A)
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Argument Definitions についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!