MATLAB Answers

0

LaTex with 2 strings separated by a num2str

Asked by Jacob Yarinsky on 19 Apr 2019
Latest activity Commented on by Star Strider
on 19 Apr 2019
Hi all, I have what I hope to be a simple question. This is the code I am working on now.
errordisplay=[' $\varepsilon_{RTP}=$ ',num2str(rtep),];
text(30,15,errordisplay,'interpreter','latex')
I want to add a percent sign after the conversion of 'rtep'. But when I do this
errordisplay=[' $\varepsilon_{RTP}=$ ',num2str(rtep),'%'];
the conversion of ' $\varepsilon_{RTP}=$ ' goes away and leaves the string as typed.
Any ideas?
Thanks in advance

  0 Comments

Sign in to comment.

2 Answers

Answer by Star Strider
on 19 Apr 2019
 Accepted Answer

Try this:
errordisplay=[' $\varepsilon_{RTP}=$ ',num2str(rtep),'\%'];
It seems you need to ‘escape’ the ‘%’.

  2 Comments

As always, my pleasure.

Sign in to comment.


Answer by David Wilson on 19 Apr 2019

Use an escape (backslash) for the %
errordisplay=[' $\varepsilon_{RTP}=$ ',num2str(rtep),'\%'];

  0 Comments

Sign in to comment.