Storing Special Characters in Cell String

11 ビュー (過去 30 日間)
Sean
Sean 2011 年 10 月 26 日
コメント済み: Amit Singh 2018 年 6 月 14 日
I am trying to create a cell array of strings to pass to the MATLAB Report Generator and convert to a table. I want to insert special characters (specifically lowercase sigma) but am having trouble. I tried using '\sigma' I was able to add the degree symbol (circle superscript) and <= using
char(n) % n is numeric ascii code
but I cannot find the ascii code for lowercase sigma. Below is an example of how I am assigning the string to the cell array.
L3C1(1,4) = {['% Count ',char(242),num2str(TempLimit),char(176),'F']};
Is there a better way to store special characters in a string? I am using MATLAB R2011a (64 bit), Windows 7.
Any help would be greatly appreciated.
Thanks
Sean

回答 (3 件)

Walter Roberson
Walter Roberson 2011 年 10 月 26 日
You can see there that are several different sigma. If you want the one that is typically used to represent standard deviation, then that would be "Greek Lower-Case Letter Sigma", unicode +03C3 . In MATLAB that would be char(hex2dec('03C3'))
However, I do not know whether the report generator is able to handle characters beyond char(255). If it is, then it might be necessary to create a UTF-8 or UTF-16 encoding of the character. The UTF-8 encoding would be
char(unicode2native(char(hex2dec('03c3')),'UTF-8'))
  1 件のコメント
Sean
Sean 2011 年 10 月 26 日
char(hex2dec('03C3')) displays (#)
char(unicode2native(char(hex2dec('03c3')),'UTF-8')) displays (I# with two dots above the capital I)

サインインしてコメントする。


Daniel Shub
Daniel Shub 2011 年 10 月 26 日
char(963)
  2 件のコメント
Sean
Sean 2011 年 10 月 26 日
char(963) shows the number sign (#)
Amit Singh
Amit Singh 2018 年 6 月 14 日
Where can I find the list of matlab ascii characters? I want to use characters relating to audio signals namely pause, play and stop.

サインインしてコメントする。


Sean
Sean 2011 年 10 月 26 日
Could this be an issue with my computer?
char(963)
displays (#) sign. Do different OS interpret character codes differently?
  3 件のコメント
Sean
Sean 2011 年 12 月 10 日
sigma plus zero
Walter Roberson
Walter Roberson 2011 年 12 月 11 日
Evaluate 'σ' + 0 as an expression at the MATLAB command prompt. You should get back a number (e.g., 963). That number is the number you would use in char() to create the sigma. Or, of course, you could just try coding 'σ' where you want sigma.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by