Space in a text is taken as line break in UIcontrol
4 次查看(过去 30 天)
显示 更早的评论
I have a long string variable like this.
tex = "Date=09-Jul-2024 Delta_E=-3.3317 Delta_U=300-320V Sigma=0.094335 MaxAbs=0.00056882 MeanAbs=-0.079426 MaxRel=0.012132 eanRel=-0.9771 AllowedDeviation=0.05-0.1"
I am trying to represent this in a fig as UIcontrol using this line of code
txt_title = uicontrol('Style', 'text', 'String',tex,'FontSize',10,'Position', [100 200 180 150]);
But space in the string variable is read as line break. Why is that, i tried removing linebreak using strtrim, erase(tex,char(10)). But nothing is working.
I need this in one line and not like this. What is the error? Thank you.
回答(1 个)
Sourabh
2024-7-9
This behaviour could likely be due to the width of the control not being wide enough to display the entire string on one line.
figure;
tex = "Date=09-Jul-2024 Delta_E=-3.3317 Delta_U=300-320V Sigma=0.094335 MaxAbs=0.00056882 MeanAbs=-0.079426 MaxRel=0.012132 eanRel=-0.9771 AllowedDeviation=0.05-0.1";
% Reducing font size and increasing width of the control
txt_title = uicontrol('Style', 'text', 'String',tex,'FontSize', 8, 'Position', [100 200 500 150]);
As you can see, by changing the width of the control to 500, it is possible to accomodate more text in each line. You can even try using different fonts and altering parameters like 'Font Size'.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Interactive Control and Callbacks 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!