Reputation: 8327
I want to display a multi-line list of instructions in a window, that is shown when I run my script.
I've tried the code below, but I don't want to have to 'fine tune' the x,y position of each line. Is there a way to quickly specify and display multiple lines of text to a window, like a figure window?
In VisualBasic, for example, this would be like appending text to a label.
f = figure('menu','none','toolbar','none');
uicontrol('Style','text','Position',[0 45 120 20],'String','AAA');
Upvotes: 2
Views: 105
Reputation: 13943
You can use sprintf
and \n
to get multiple lines. The additional HorizontalAlignment
-property aligns the text horizontally. Then you just need to fine fine-tune the overall position.
f = figure('menu','none','toolbar','none');
txt = sprintf('Line 1\nA longer line 2\nLine 3');
uicontrol('Style','text','Position',[30 45 180 40],'String',txt,...
'HorizontalAlignment','left');
This looks like this:
Upvotes: 3