Filter löschen
Filter löschen

How to display numerical data as subscript text in the UIAxes in App Designer when the data has multiple digits?

3 Ansichten (letzte 30 Tage)
Hi,
So I'm trying to create shapes in App Designer and insert labels within each shape. I'm using a for-loop to do this. Each index of the for-loop is referenced in creating part of the label for the shapes in the UIAxes. The sprintf function is used to convert the data into a string to display it at some coordinates. Here's an example:
text(app.UIAxes,50, 50, sprintf('%s_%d_%d', 'd^q',1,5), 'Fontsize',40)
axis([0 100 0 100])
The issue I've encountered is when this code is used, it provides the label where (d^q)_5. When I run this similar code in a Matlab script file, it works fine providing me with (d^q)_15.
Similar code:
text(50, 50, sprintf('%s_%d_%d', 'd^q',1,5), 'Fontsize',40)
axis([0 100 0 100])
It shows the number "15" as the subscript of "d" to the superscript of "q". I have no idea how to fix this. Please help me or tell me if it is even possible.

Akzeptierte Antwort

Kai Domhardt
Kai Domhardt am 7 Feb. 2018
You can use curley brackets to specify where the sup-/superscript starts and ends. See Text, under Interpreter.
text(app.UIAxes,0, 0.5, sprintf('%s_{%d_%d}}', 'd^{q',1,5), 'Fontsize',40)
would be 1 as subscript of q and 5 as subscript of 5.
If you just want 1 and 5 as subscript of d^q, this would do the trick:
text(app.UIAxes,0, 0.5, sprintf('%s_{%d%d}', 'd^{q}',1,5), 'Fontsize',40)

Weitere Antworten (0)

Kategorien

Mehr zu Develop Apps Using App Designer finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by