how to display matrix in msg box
13 次查看(过去 30 天)
显示 更早的评论
Hi
I would like to display til following matrix in a msgbox, so they are placed nicely is in a normal matrix.
I found this code, but the values are not writtes as in a matrix, but more link in a txt file.
if somebody knows how to fix this, I would be happy!
if true
MGF =
7 7 4 7
12 10 10 12
-3 7 2 -3
10 12 12 12
7 4 10 10
12 12 10 12
0 -3 2 -3
7 10 7 10
12 12 12 12
5 13 8 10
12 NaN NaN 12
msgbox(num2str(MGF))
end
0 个评论
采纳的回答
更多回答(3 个)
Pawel Jastrzebski
2018-1-11
编辑:Pawel Jastrzebski
2018-1-11
Your MGF isn't a matrix. Encompass it with [] and ; for row separation and it should work. See the example below:
m = randi(5,6)
msgbox(num2str(m))
0 个评论
Signe Carlslund Kristensen
2018-1-11
1 个评论
Pawel Jastrzebski
2018-1-11
I don't think it's possible to have the matrix values perfectly aligned in the message box. But if you think about it, message box is a 'Figure' object. So instead of using 'msgbox', plot your data with i.e. heatmap and remove all of the formatting and you'll achieve the same result.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!