[英]How to plot character matrix with Matlab?
I'd like to plot a character matrix in Matlab, for example this matrix 我想在Matlab中绘制一个字符矩阵,例如这个矩阵
M = ['test1','test2' ; M = ['test1','test2'; 'test3','test4']; 'TEST3', 'TEST4'];
Is there a simple way to implement it in Matlab? 有没有一种简单的方法在Matlab中实现它?
Thank you 谢谢
The text
command allows you to plot multiple strings at once. text
命令允许您一次绘制多个字符串。
With your example: 用你的例子:
M = {'test1','test2';'test3','test4'};
%// adjust x-multiplicator if text becomes very long
[xx,yy] = ndgrid((0:size(M,1)-1)*2+1,1:size(M,2));
figure,
th = text(xx(:),yy(:),M(:));
%// set additional properties, such as centering text horizontally and vertically
set(th,'horizontalAlignment','center','verticalAlignment','middle');
xlim([0 max(xx(:))])
ylim([0,max(yy(:))])
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.