I'd like to plot a character matrix in Matlab, for example this matrix
M = ['test1','test2' ; 'test3','test4'];
Is there a simple way to implement it in Matlab?
Thank you
The text command allows you to plot multiple strings at once.
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(:))])
(...,'horizontalalignment', 'center',...) text properties can be found at: gnu.org/software/octave/doc/interpreter/…
text. You can define a grid of coordinates and use a loop to add the letters to the figure