The command textallows you to create multiple lines at once.
In 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(:))])
Jonas source
share