Space in a text is taken as line break in UIcontrol
4 views (last 30 days)
Show older comments
Govind Sankar Madhavan Pillai Ramachandran Nair
on 9 Jul 2024
Commented: Govind Sankar Madhavan Pillai Ramachandran Nair
on 9 Jul 2024
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.
Answers (1)
Sourabh
on 9 Jul 2024
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 Comments
See Also
Categories
Find more on Interactive Control and Callbacks in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!