Convert string into greek letters
4 次查看(过去 30 天)
显示 更早的评论
john
2012-6-12
Hi,
I have edit text in GUI. If I write into edit text for example aplha, is possible to convert string into greek letter?
3 个评论
john
2012-6-12
:)
In matrix UserData.matrix.....is possible to convert string into greek letter and than insert into cell matrix? And also I will make symbolical and numerical calculations.
Now I am using this commands:
1. UserData.matrix(3,1)=num2cell(sym(get(handles.edit5,'string'))); % for load string in one part of code
2. UserData.info(4,1)=num2cell(sym(UserData.matrix{4,1})); % to print string in uitable, this code is in other part of code
3. D(4,1)=sym(UserData.info{4,1});
4. result(4,1)=cellstr(char(D(4,1))); % result is in uitable
john
2012-6-14
Or is possible to convert data into greek letter for uitable? So in uitable will be greek letters.
采纳的回答
Walter Roberson
2012-6-14
Try for example
uitable('Data',num2cell(char(945:969).'))
24 个评论
Walter Roberson
2012-6-14
Works fine for me on Ubuntu 10.04 (Linux) under MATLAB R2007a, R2008b, R2010b
john
2012-6-16
Here is my code:
h=findobj(0,'Type','figure','Tag','figure1');
UserData=get(h,'UserData');
function pushbutton12_Callback(hObject, eventdata, handles)
uitable('Data',num2cell(char(945:969).'))
set(h,'UserData',UserData);
guidata(hObject, handles);
Result of this code-in uitable will appear 25 rows with symbol square.
I have Matlab 7.12.0.635 (R2011a), Windows XP and also Vista. I don't know, what is wrong. Do I have make some settings in uitable properties?
Walter Roberson
2012-6-16
Please check your system Regional Settings and see if you are set to a particular Code Page for your character set; please also let us know what Language you are set to.
The codes 945 to 969 are the Unicode codes for the lower-case greek characters. If you are set to a particular code page, they might be in a different place or they might not be available at all.
john
2012-6-18
I don't know change "Change system locale", because my program has to work without changing of any Regional and Language Options. And I'm not sure, that I have to make some changes, because this code works correctly
text(.5,.5,texlabel('alpha)).
But, this is only for the text, and I need it for the uitable. :(
john
2012-6-18
foo = uitable('Data', {'<HTML>1+α'}) works,
but all informations ( columns and rows ) I have in matrix result. How can I change your code to my situation?
Walter Roberson
2012-6-18
Let S be your cell array to convert, and let each element of S be in char() form (you need an additional step if they are in sym form)
T = regexprep(S, 'alpha', 'α');
T = regexprep(T, 'beta', 'β');
T = regexprep(T, 'gamma', 'γ')
....
T = regexprep(T, 'omega', 'ω');
then set the uitable Data property to be T .
john
2012-6-20
1. how can I group together command <HTML> and T.
.
.
T = regexprep(result(4,1), 'alpha', 'α')
t = uitable('Parent',f,'Data',{'<HTML>&',T})???
2. I need also index...for example, alpha23....number 23 has to be smaller than greek letter aplha
Walter Roberson
2012-6-20
t = uitable('Parent', f, 'Data', strcat('<HTML>',T) )
For subscript 23, use
<SUB><FONT SIZE=-2>23
For example,
reppat = '$1;<SUB><FONT SIZE=-1>$2</FONT>/<SUB>';
T = regexprep(S, '(alpha)(\d+)', reppat);
T = regexprep(T, '(beta)(\d+)', reppat);
T = regexprep(T, '(gamma)(\d+)', reppat);
and so on.
john
2012-6-21
1. t = uitable('Parent', f, 'Data', strcat('<HTML>',T) ) works great.
2. reppat = '$1;<SUB><FONT SIZE=-1>$2</FONT>/<SUB>';
T = regexprep(S, '(alpha)(\d+)', reppat);
....result is alpha;3/. Not greek letter. It can happen, that there will be alpha2beta4, so base on code in point 2. , than 2beta4 will be smaller chars, but beta has to be also bigger char. So this code is not so good.
john
2012-6-21
Do you know change you code? If I have for example Capacitor23, then Capacitor has big size of chars and 23 are smaller ? Do you knok do this?
john
2012-6-21
And if I write only alpha, then code doesn't works, only with some number like alpha34
Walter Roberson
2012-6-21
I think this should do it:
T = regexprep(S, '([A-Za-z]+)(\d+)', '$1<SUB><FONT SIZE=-1>$2</FONT></SUB>');
T = regexprep(T, '(alpha|beta|gamma|delta|epsilon|zeta|eta|theta|iota|kappa|lambda|mu|nu|xi|omicron|pi|rho|sigma|tau|upsilon|phi|chi|psi|omega', '&$1;', 'preservecase');
This should also handle upper-case greek letters.
john
2012-6-25
those greek letters works corretly :T = regexprep(T, '(alpha|beta|gamma|delta|epsilon|zeta|eta|theta|iota|kappa|lambda|mu|nu|xi|pi|rho|sigma|tau|upsilon|phi|chi|psi|omega|Gamma|Delta|Theta|Lambda|Xi|Pi|Sigma|Upsilon|Phi|Psi|Omega|tau|equiv|otimes|cap|int|perp|ni|cong|oplus|cup|times|oslash|o|nabla)', '&$1;');
Other letters from http://www.clemson.edu/ces/crb/procedures/greek/mat_greek.htm doesn't work. For example, if I write varsigma, then I get &varsigma, not greek letter....where can be I problem?
Walter Roberson
2012-6-25
varsigma is not an HTML character entity. HTML appears to call it sigmav . See http://www.w3.org/TR/WD-math-970515/table04.html
john
2012-6-25
In code I use sigmav. What I should write into edit text for correct convert into greek letter? sigmav or varsigma? If I write sigmav, I get &sigmav. If I write varsigma, I get var and greek letter sigma. So, it is not good.
john
2012-7-1
编辑:Walter Roberson
2012-7-1
Hi, sigma and sigmaf are OK. But theta and thetasym not. If I write thetasym I get symbol theta + sym for this code
T = regexprep(T, '(Alpha|Beta|Gamma|Delta|Epsilon|Zeta|Eta|Theta|Iota|Kappa|Lambda|Mu|Nu|Xi|Omicron|Pi|Rho|Sigmaf|Sigma|Tau|Upsilon|Phi|Chi|Psi|Omega|alpha|beta|gamma|delta|epsilon|zeta|eta|theta|iota|kappa|lambda|mu|nu|xi|omicron|pi|rho|sigmaf|sigma|tau|upsilon|phi|chi|psi|omega|thetasym|upsih|piv)', '&$1;');
but for this code
T = regexprep(T, '(thetasym|piv)', '&$1;');
is OK, but I need code for all letters.
john
2013-2-27
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, '(Alpha|Beta|Gamma|thetasym|piv|Delta|Epsilon|Zeta|Eta|Theta|Iota|Kappa|Lambda|Mu|Nu|Xi|Omicron|Pi|Rho|Sigmaf|Sigma|Tau|Upsilon|Phi|Chi|Psi|Omega|alpha|beta|gamma|delta|epsilon|zeta|eta|theta|iota|kappa|lambda|mu|nu|xi|omicron|pi|rho|sigmaf|sigma|tau|upsilon|phi|chi|psi|omega|upsih|lsquo|rsquo|sbquo|ldquo|rdquo|bdquo|dagger|Dagger|bull|hellip|permil|prime|Prime|lsaquo|rsaquo|oline|euro|trade|larr|uarr|rarr|darr|harr|crarr|loz|spades|clubs|hearts|diams|forall|part|exist|empty|nabla|isin|notin|ni|prod|sum|minus|lowast|radic|prop|infin|ang|and|or|cap|cup|int|sim|cong|asymp|ne|equiv|le|ge|sube|supe|sub|sup|nsub|oplus|otimes|perp|sdot)', '&$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 subscript, so 2U2 must by subscript.
Thank you
john
2013-4-23
Hi, how can I insert sqrt into uitable? for example sqrt(2).
Surd doesn't help.
Thank you
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Labels and Annotations 的更多信息
标签
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!发生错误
由于页面发生更改,无法完成操作。请重新加载页面以查看其更新后的状态。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
亚太
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)