Subscript after greek alphabet

Hi,
could you help me please? This is me code:
vd=size(UserData.info);
for i= 0:vd(1)-4
T = regexprep(cellstr(char(sym(UserData.matrix{4+i,1}))), '([A-Za-z]+)(\d+)', '$1<FONT SIZE=-1>$2</FONT>');
T = regexprep(T, '(phi|alpha|beta|gamma|delta|epsilon|zeta|eta)', '&$1;');
result(4+i,1)=strcat('<HTML>',T);
end;
Code makes: if I write for example U1U2, than all numbers are subscript. But I need phi2U2, than everything after "phi" must be always subscript, so 2U2 must by subscript.
Thank you

1 comentario

It could be done, but with the requirement you have given, if you had something like
phi2u2+gamma8
then what you wrote would expect that {2u2+gamma8} would all be subscripted instead of just the 2u2 -- because you wrote that "everything after "phi" must always subscript" and the +gamma8 is "after "phi""

Iniciar sesión para comentar.

Respuestas (1)

Juan Camilo Medina
Juan Camilo Medina el 5 de Mzo. de 2013

0 votos

It depends on what kind of interpreter you have set up, but the default Matlab math and Greek letters format follow latex style, so you would need:
\phi_{2U2} % whatever is between the brackets will be subscript
to get what you want

9 comentarios

john
john el 5 de Mzo. de 2013
please, can you aplicate your idea to my code?
john
john el 5 de Mzo. de 2013
Editada: john el 5 de Mzo. de 2013
into static text I write for example U1.
In code I generate U1sin(omegat+phiU1)....with old code all numbers are subscript. That is correct, but always after phi I need all like subscript. Chars after phi I take also from static text.
Please can you help me?
Jan
Jan el 6 de Mzo. de 2013
@John: I still do not understand, what you want. Which part of which string should be displayed as subscript in which uicontrol?
john
john el 7 de Mzo. de 2013
@Jan Simon: After some string only numbers should be subscript, and after "phi" everything=numbers and strings should be subscript. For example U1sin(omegat+phiU1)--the first "1" must be subscript. "U1" after phi must be also subscript.
Walter Roberson
Walter Roberson el 8 de Mzo. de 2013
And if it was U1sin(phiU1+omegat) then [U1+omega[T]] would all be one subscript ?
john
john el 11 de Mzo. de 2013
yes,,, and also if there will be U1sin(phiU1+omegat+phiU2+omegat) [U1+omega[T]] would be one subscript, then normal phi and then [U2+omega[T]] would be one subscript
Then you need to define rules as to when the extended subscript would end. Does it end when the next "phi" (specifically!) starts? Does it end when the next phi|alpha|beta|gamma|delta|epsilon|zeta|eta starts? If there had been (say)
U1sin(phiU1+(omega-1)^2)
then would the entire U1+(omega-1)^2 be subscripted? If it is to be subscripted then the logic cannot be done using standard regular expressions, as the logic would require matching ')' to determine whether the subscript was finished or not. The regexp() package does not actually use standard regular expressions, but it gets pretty icky to try to program matching subexpressions that can have nested operations.
john
john el 11 de Mzo. de 2013
Does it end when the next "phi" (specifically!) starts ...yes!!!
There will be only form U1sin(omegat+phiU1U2U3phiU4U5)....does it help?
john
john el 13 de Mzo. de 2013
Please, exist there any solution?

Iniciar sesión para comentar.

Categorías

Más información sobre Labels and Annotations en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 4 de Mzo. de 2013

Community Treasure Hunt

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

Start Hunting!

Translated by