Html code used along with Matlab

I have recently found that Matlab can use LaTeX character sequences. However, they only can be used by the functions text, title, xlabel, ylabel and zlabel. I have designed a GUI in which has an uitable. Its header is a string that uses HTML code and looks like this:
header = {'<center>Component X<br />(km/s^2)</center>', ...
'<center>Component Y<br />(km/s^2)</center>', ...
'<center>Component Z<br />(km/s^2)</center>'};
My intention is replacing s^2 with s squared. Because of I can not use LaTeX characters inside the string "header" (at least I had tried it and it did not work), I would like to know how I could do it if I use HTML code which I do not know.

 채택된 답변

Jan
Jan 2011년 11월 20일

1 개 추천

Another approach:
header = {'<center>Component X<br />(km/s&sup2;)</center>', ...
'<center>Component Y<br />(km/s&sup2;)</center>', ...
'<center>Component Z<br />(km/s&sup2;)</center>'};
Well, the display of the HTML characters in this forum drives my crazy. Th "²" is written as "& s u p 2 ;" without the spaces.

추가 답변 (1개)

Walter Roberson
Walter Roberson 2011년 11월 20일

1 개 추천

header = {'<center>Component X<br>(km/s<sup><font size="-1">2</font></sup>)</center>', ...
'<center>Component Y<br />(km/s<sup><font size="-1">2</font></sup>)</center>', ...
'<center>Component Z<br />(km/s<sup><font size="-1">2</font></sup>)</center>'};
Note: you can leave off the </html> tags in practice.

댓글 수: 6

Julián Francisco
Julián Francisco 2011년 11월 20일
@Walter Roberson: Thank you for your answer. I do not understand what your note means.
Walter Roberson
Walter Roberson 2011년 11월 20일
My note means that the following will also function:
header = {'<html><center>Component X<br>(km/s<sup><font size="-1">2</font></sup>)</center>', ...
'<html><center>Component Y<br />(km/s<sup><font size="-1">2</font></sup>)</center>', ...
'<html><center>Component Z<br />(km/s<sup><font size="-1">2</font></sup>)</center>'};
Julián Francisco
Julián Francisco 2011년 11월 20일
@Walter Roberson: Thank you for your explanation.
Julián Francisco
Julián Francisco 2011년 11월 20일
@Walter Roberson: I have proved your code but the command
<font size="-1">2</font>
has not effect on the superindex size (if I delete this part of the code, I get the same result). However, if I use the code given by Jan Simon, it does works. Can anybody explain me why?
Walter Roberson
Walter Roberson 2011년 11월 20일
The implemented HTML is not the full set of HTML and it is often difficult to predict what will work and what will not.
Jan's version works by inserting a particular character that is specifically a raised 2; my version (if it worked) would be the general HTML mechanism to raise text with a lower size.
Julián Francisco
Julián Francisco 2011년 11월 20일
@Walter Roberson: Thank you for your explanation. However, if both codes are HTML's ones, they should work correctly, independently of its general or particular character (I do not understand nothing. It should be matters of computing).

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

카테고리

도움말 센터File Exchange에서 App Building에 대해 자세히 알아보기

제품

태그

질문:

2011년 11월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by