이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
Convert string into greek letters
조회 수: 9 (최근 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.
Walter Roberson
2012년 6월 21일
Sorry, reppat should be
reppat = '&$1;<SUB><FONT SIZE=-1>$2</FONT></SUB>';
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월 21일
It not possible what did you do :).
I little changed your code, but big thanks again.
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 (한국어)