MATLAB: Adding Superscript to a string

superscript

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?

Best Answer

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