Hi guys i am new to forums.
my issue is as follows. I have a string to which other strings are concatenated. I want some of them to be in superscript. code is as follows
for i = 1:(length(p)-1)
str = [str,num2str(p(i)), 'X' , (num2str(length(p) -i)), ' + '];
end
i want the portion (num2str(length(p) -i)) to be in superscript but it seems to be posing constant problem as i cannot use the 'abc^{def]' to simply put it in superscript.
any ideas?

댓글 수: 2

Jan
Jan 2013년 11월 10일
Strings are vectors of type char. So they cannot have any superscript properties, because the appearance of the string is controlled by the interpreter. Therefore it matters, where this string should appear.
While the creation and the contents of the string does not matter, it is required to show us the the command you use to display the string.
I use the gtext() command to display the results on to a graph
gtext(str);

댓글을 달려면 로그인하십시오.

 채택된 답변

Walter Roberson
Walter Roberson 2013년 11월 10일

0 개 추천

Try experimenting with
str = [str, num2str(p(i)), 'X\textsuperscript{', num2str(length(p) -i), '} + '];

댓글 수: 3

Ali
Ali 2013년 11월 10일
Nope it just displays the whole thing inside the quotes. including \textsuperscript.
however it gives me a warning
Warning: Unable to interpret TeX string "\textsuperscript{3} + -7.5235X\textsuperscript{2} + 2.5532X\textsuperscript{1} + "
str = [str, num2str(p(i)), 'X^{', num2str(length(p) -i), '} + '];
That fixes the problem Thank you walter you gave me the inspiration :D
Sameed Ahmed
Sameed Ahmed 2022년 2월 9일
@Ali your method worked for me. Thanks!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Data Type Identification에 대해 자세히 알아보기

태그

질문:

Ali
2013년 11월 9일

댓글:

2022년 2월 9일

Community Treasure Hunt

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

Start Hunting!

Translated by