Horzcat error with num2str in disp function.
1 次查看(过去 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!