Graphics |
Example -- Multiline Text
MATLAB supports multiline text strings using cell arrays. Simply define a string variable as a cell array with one line per cell. This example defines two cell arrays, one used for a uicontrol
and the other as text
.
str1(1) = {'Center each line in the Uicontrol'}; str1(2) = {'Also check out the textwrap function'}; str2(1) = {'Each cell is a quoted string'}; str2(2) = {'You can specify how the string is aligned'}; str2(3) = {'You can use LaTeX symbols like \pi \chi \Xi'}; str2(4) = {'\bfOr use bold \rm\itor italic font\rm'}; str2(5) = {'\fontname{courier}Or even change fonts'}; plot(0:6,sin(0:6)) uicontrol('Style','text','Position',[80 80 200 30],... 'String',str1); text(5.75,sin(2.5),str2,'HorizontalAlignment','right')
Using Character and Numeric Variables in Text | Drawing Text in a Box |
© 1994-2005 The MathWorks, Inc.