I am begining to learn MATLAB. MATLAB has a LATEX engine, but I so not know nothing about it.
I have a problem. I need to place an annotation in a MATLAB figure that use superscript, with more than one character, but not a fixed string, but instead a string variable, with a contents that changes over different runs. I have use {} curly braces, to enclose the variable name, but the only thin I’ve got is the variable label name as a superscript not its contents.
Can you help me in any way?
I guess that is a MATLAB question rather than a LATEX question. In matlab, you first make the string, and then put the string to a place where you want to display. For example, if you want to display “run 123″ as the title of the figure, where 123 is your current iteration count, then you can do
Here, the content of the variable “iter” is 123, the function “num2str” converts a number to a string, and we concatenate two strings: “run ” and “123″. Then we use the “title” command to display the title on the figure.
Thank you very much for your prompt answer.What you say in your email I’ve already tried before your email and it works. The problem is not what you say, Change ‘run ‘ by ’2^ ‘instead and try to elevate to 123 and then to 124…and so on, with a same line in the program. The problem is superscript. By the way, if you try the way you show in ypur email you will get 2 elevated to 1 and 23 will be droped from the superscript.
Thank you very much for your help, but.. no way. I have tried in MATLAB many more possibilities according with your clue but nothing. I suppose it will be a built-in limitation on MATLAB Latex engine. I am sending you two attachments by personal email because it is not possible do this in the forum. Frist is a matlab editor screen capture, not recognizing even the function num2str, because o de apostrophes. Second file consists of two code lines that resembles your proposed solution.
Hi
I am begining to learn MATLAB. MATLAB has a LATEX engine, but I so not know nothing about it.
I have a problem. I need to place an annotation in a MATLAB figure that use superscript, with more than one character, but not a fixed string, but instead a string variable, with a contents that changes over different runs. I have use {} curly braces, to enclose the variable name, but the only thin I’ve got is the variable label name as a superscript not its contents.
Can you help me in any way?
Sincerely
I guess that is a MATLAB question rather than a LATEX question. In matlab, you first make the string, and then put the string to a place where you want to display. For example, if you want to display “run 123″ as the title of the figure, where 123 is your current iteration count, then you can do
title_str = ['run ' num2str(iter)];
title(title_str);
Here, the content of the variable “iter” is 123, the function “num2str” converts a number to a string, and we concatenate two strings: “run ” and “123″. Then we use the “title” command to display the title on the figure.
Hi Jie
Thank you very much for your prompt answer.What you say in your email I’ve already tried before your email and it works. The problem is not what you say, Change ‘run ‘ by ’2^ ‘instead and try to elevate to 123 and then to 124…and so on, with a same line in the program. The problem is superscript. By the way, if you try the way you show in ypur email you will get 2 elevated to 1 and 23 will be droped from the superscript.
Thank you very much.
Sorry that I did not have access to matlab in the past week. Now that I try something like:
iter = 123;
title_str = ['2^{' num2str(iter) '}'];
title(title_str);
I am sure that title_str will become ’2^{123}’, and the part ’123′ will show exactly as a superscript. Perhaps you just missed the curly braces.
Hi Jie
Thank you very much for your help, but.. no way. I have tried in MATLAB many more possibilities according with your clue but nothing. I suppose it will be a built-in limitation on MATLAB Latex engine. I am sending you two attachments by personal email because it is not possible do this in the forum. Frist is a matlab editor screen capture, not recognizing even the function num2str, because o de apostrophes. Second file consists of two code lines that resembles your proposed solution.
Thank you very much