[Reproduced] Matlab multiple lines of static text output

Reprinted articles, the original link: Matlab static display multi-line text box

Sometimes we use in the GUI static text box displays the results of the program, but the result is very long, and his party may not be displayed in the open, but not edit or static text box to display the listbox as a multi-line through the scroll bar, even set up max and min attribute is the same.

So, how to display multiple lines makes sense in a static text box.

Solution

Using the function textwrap

figure('units', 'normalized', 'position', [0.4 0.4 0.4 0.3]);
h = uicontrol('Style','Text','fontsize',16);
string = {'静态文本框为什么是静态的?','因为不能像编辑框一样滚动显示其中的内容',...
    '如果想在静态文本框中多行显示','按照这种方式就可以实现','调用textwrap函数啊!'};
[outstring, newpos] = textwrap(h, string);
set(h,'String', outstring, 'Position', newpos);

show result

Here we need to note that the middle row is best not to have spaces, if any, will it function assigned into two paragraphs.
Matlab static display multi-line text box

Guess you like

Origin www.cnblogs.com/airbird/p/11455241.html