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

2 次查看(过去 30 天)
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.

采纳的回答

Kai Domhardt
Kai Domhardt 2018-2-7
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)

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Develop Apps Using App Designer 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by