Space in a text is taken as line break in UIcontrol
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Govind Sankar Madhavan Pillai Ramachandran Nair
le 9 Juil 2024
Commenté : Govind Sankar Madhavan Pillai Ramachandran Nair
le 9 Juil 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.
Réponses (1)
Sourabh
le 9 Juil 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 commentaires
Voir également
Catégories
En savoir plus sur Interactive Control and Callbacks dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!