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.
댓글 수: 0
채택된 답변
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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File 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!