From: Hans on 19 Jan 2010 01:35 "Bruno Luong" <b.luong(a)fogale.findmycountry> wrote in message <hj1eif$chl$1(a)fred.mathworks.com>... > "Hans " <jyde_6(a)msn.com> wrote in message <hj1bmj$9an$1(a)fred.mathworks.com>... > > "Bruno Luong" <b.luong(a)fogale.findmycountry> wrote in message <hj13g3$k23$1(a)fred.mathworks.com>... > > > "Hans " <jyde_6(a)msn.com> wrote in message <hj111c$ego$1(a)fred.mathworks.com>... > > > > Hello everybody > > > > > > > > > > > > How can I get sprintf to a write a string in latex? > > > > > > > > Example: > > > > > > > > y_1=[1 2 3 4] > > > > sprintf('%.0f \alpha\n', y_1) > > > > > > > > > > Replace \ with \\ > > > > > > Bruno > > > > Hi Bruno and kinor > > > > If I try: > > > > y_1=[1 2 3 4] > > sprintf('%.0f \\alpha\n', y_1) > > > > I get : > > >> sprintf('%.0f \\alpha\n', y_1) > > > > ans = > > > > 1 \alpha > > 2 \alpha > > 3 \alpha > > 4 \alpha > > > > I want it to show the alpha in symbol? > > You confuse, sprintf format the simple *string* (char array), the TeX/LaTex interpretation come later, when the string is used in graphic command such as XLABEL, TITLE... > > Bruno Dear Bruno and Kinor Thank very much for taking time to help me. Sorry for confusing you. I will try to explain my problem again. I have a gui and I want to make a string that is output in a text window. I can not get it to show the alpha symbol? My original GUI is more complicated where I have some listboxes where I can choose different data series that are imported and shown in the text window. Example: function test6() global vectorOfValues vectorOfValues = []; f=figure('name','test',... 'numbertitle','off',... 'menubar','none',... 'color',[0.85, 0.85, 0.85],... 'units','normalized',... 'position',[0 0.1 0.95 0.87]); col=get(f,'color'); ht2=uicontrol('style','text',... 'units','normalized',... 'position',[0.5, 0.3,0.4 0.5],... 'backgroundcolor',[0.95, 0.95, 0.95],... 'string','',... 'fontsize',15); y=[10 20 30 40] set(ht2,'string',sprintf('%.0f \\alpha\n',y)) end Hope the example illustrate my problem with showing symbols in text window by using string input from set function. Best Regards Hans
From: Steven Lord on 19 Jan 2010 10:19 "Hans " <jyde_6(a)msn.com> wrote in message news:hj3jqp$8e7$1(a)fred.mathworks.com... > "Bruno Luong" <b.luong(a)fogale.findmycountry> wrote in message > <hj1eif$chl$1(a)fred.mathworks.com>... *snip* > Thank very much for taking time to help me. Sorry for confusing you. I > will try to explain my problem again. I have a gui and I want to make a > string that is output in a text window. I can not get it to show the alpha > symbol? Uicontrols do not have an Interpreter property and so cannot interpret TeX commands. Text objects do have an Interpreter property and so can interpret TeX in their String property. http://www.mathworks.com/access/helpdesk/help/techdoc/infotool/hgprop/text_frame.html But note that text objects can't be children of a figure window (like uicontrols can), but must be a child of an axes, hggroup, or hgtransform object as documented in the description of the Parent property. -- Steve Lord slord(a)mathworks.com comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
From: Yair Altman on 19 Jan 2010 12:34 "Steven Lord" <slord(a)mathworks.com> wrote in message <hj4iij$2bm$1(a)fred.mathworks.com>... > > "Hans " <jyde_6(a)msn.com> wrote in message > news:hj3jqp$8e7$1(a)fred.mathworks.com... > > "Bruno Luong" <b.luong(a)fogale.findmycountry> wrote in message > > <hj1eif$chl$1(a)fred.mathworks.com>... > > *snip* > > > Thank very much for taking time to help me. Sorry for confusing you. I > > will try to explain my problem again. I have a gui and I want to make a > > string that is output in a text window. I can not get it to show the alpha > > symbol? > > Uicontrols do not have an Interpreter property and so cannot interpret TeX > commands. > > Text objects do have an Interpreter property and so can interpret TeX in > their String property. > > http://www.mathworks.com/access/helpdesk/help/techdoc/infotool/hgprop/text_frame.html > > But note that text objects can't be children of a figure window (like > uicontrols can), but must be a child of an axes, hggroup, or hgtransform > object as documented in the description of the Parent property. > > -- > Steve Lord > slord(a)mathworks.com > comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ I am not exactly sure what the OP meant: 1. You can create an axes and use the \alpha Tex notation in the text() function. The axes background and borders can be made transparent, which enables displaying Tex labels anywhere in your figure (but beneath uicontrols). 2. Alternately, you can use a Matlab button uicontrol, and set the alpha symbol using HTML (alpha = &# 945;), as explained here: http://undocumentedmatlab.com/blog/html-support-in-matlab-uicomponents/ 3. Alternately, you can use a Java JLabel control, and set the alpha symbol using HTML, as explained here: http://undocumentedmatlab.com/blog/customizing-matlab-labels/ 4. Alternately, you can display the alpha symbol within an HTML-based edit-pane, as explained here: http://undocumentedmatlab.com/blog/gui-integrated-html-panel/ There are several other variants, but these should be sufficient for most use-cases. Yair Altman http://UndocumentedMatlab.com
From: Hans on 20 Jan 2010 01:58 "Yair Altman" <altmanyDEL(a)gmailDEL.comDEL> wrote in message <hj4qf1$9c7$1(a)fred.mathworks.com>... > "Steven Lord" <slord(a)mathworks.com> wrote in message <hj4iij$2bm$1(a)fred.mathworks.com>... > > > > "Hans " <jyde_6(a)msn.com> wrote in message > > news:hj3jqp$8e7$1(a)fred.mathworks.com... > > > "Bruno Luong" <b.luong(a)fogale.findmycountry> wrote in message > > > <hj1eif$chl$1(a)fred.mathworks.com>... > > > > *snip* > > > > > Thank very much for taking time to help me. Sorry for confusing you. I > > > will try to explain my problem again. I have a gui and I want to make a > > > string that is output in a text window. I can not get it to show the alpha > > > symbol? > > > > Uicontrols do not have an Interpreter property and so cannot interpret TeX > > commands. > > > > Text objects do have an Interpreter property and so can interpret TeX in > > their String property. > > > > http://www.mathworks.com/access/helpdesk/help/techdoc/infotool/hgprop/text_frame.html > > > > But note that text objects can't be children of a figure window (like > > uicontrols can), but must be a child of an axes, hggroup, or hgtransform > > object as documented in the description of the Parent property. > > > > -- > > Steve Lord > > slord(a)mathworks.com > > comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ > > > I am not exactly sure what the OP meant: > > 1. You can create an axes and use the \alpha Tex notation in the text() function. The axes background and borders can be made transparent, which enables displaying Tex labels anywhere in your figure (but beneath uicontrols). > 2. Alternately, you can use a Matlab button uicontrol, and set the alpha symbol using HTML (alpha = &# 945;), as explained here: http://undocumentedmatlab.com/blog/html-support-in-matlab-uicomponents/ > 3. Alternately, you can use a Java JLabel control, and set the alpha symbol using HTML, as explained here: http://undocumentedmatlab.com/blog/customizing-matlab-labels/ > 4. Alternately, you can display the alpha symbol within an HTML-based edit-pane, as explained here: http://undocumentedmatlab.com/blog/gui-integrated-html-panel/ > > There are several other variants, but these should be sufficient for most use-cases. > > Yair Altman > http://UndocumentedMatlab.com Dear Yair and Steve Thank you for taking time to help me. As I understand uicontrol cannot show symbols. In my example I have a GUI with a list box where different options can be choosed. The options are then shown in a textbox when I press the pushbutton. Can you come up with an example how to solve my problem soo symbols can be shown in the textbox?Yair can you show me two examples with option 1 and 2 that you mentioned or maybe one of the others? I do not have experience with Java programming. Hope the example under can shown what I want. function test6() % global vectorOfValues % vectorOfValues = []; f=figure('name','test',... 'numbertitle','off',... 'menubar','none',... 'color',[0.85, 0.85, 0.85],... 'units','normalized',... 'position',[0 0.1 0.95 0.87]); col=get(f,'color'); uicontrol('style','pushbutton',... 'units','normalized',... 'position',[0.325 0.1 0.10 0.04],... 'string','Table',... 'backgroundcolor',col,... 'callback',@go99709); ht2=uicontrol('style','text',... 'units','normalized',... 'position',[0.5, 0.3,0.4 0.5],... 'backgroundcolor',[0.95, 0.95, 0.95],... 'string','',... 'fontsize',15); hlb576=uicontrol('style','listbox',... 'units','normalized',... 'position',[0.3 0.3 0.15 0.1],... 'string',{'y11';'y22'}); function go99709(varargin) choice=get(hlb576,'value'); if choice==1 y6=[10 20 30 40] y66=[1 2 3 4] set(ht2,'string',sprintf('%.0f \\circ %.0f min\n',[y6';y66'])) elseif choice==2 set(ht2,'string','Car price') end end end Best Regards Hans
From: Hans on 20 Jan 2010 10:57
"Hans " <jyde_6(a)msn.com> wrote in message <hj69hu$1rn$1(a)fred.mathworks.com>... > "Yair Altman" <altmanyDEL(a)gmailDEL.comDEL> wrote in message <hj4qf1$9c7$1(a)fred.mathworks.com>... > > "Steven Lord" <slord(a)mathworks.com> wrote in message <hj4iij$2bm$1(a)fred.mathworks.com>... > > > > > > "Hans " <jyde_6(a)msn.com> wrote in message > > > news:hj3jqp$8e7$1(a)fred.mathworks.com... > > > > "Bruno Luong" <b.luong(a)fogale.findmycountry> wrote in message > > > > <hj1eif$chl$1(a)fred.mathworks.com>... > > > > > > *snip* > > > > > > > Thank very much for taking time to help me. Sorry for confusing you. I > > > > will try to explain my problem again. I have a gui and I want to make a > > > > string that is output in a text window. I can not get it to show the alpha > > > > symbol? > > > > > > Uicontrols do not have an Interpreter property and so cannot interpret TeX > > > commands. > > > > > > Text objects do have an Interpreter property and so can interpret TeX in > > > their String property. > > > > > > http://www.mathworks.com/access/helpdesk/help/techdoc/infotool/hgprop/text_frame.html > > > > > > But note that text objects can't be children of a figure window (like > > > uicontrols can), but must be a child of an axes, hggroup, or hgtransform > > > object as documented in the description of the Parent property. > > > > > > -- > > > Steve Lord > > > slord(a)mathworks.com > > > comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ > > > > > > I am not exactly sure what the OP meant: > > > > 1. You can create an axes and use the \alpha Tex notation in the text() function. The axes background and borders can be made transparent, which enables displaying Tex labels anywhere in your figure (but beneath uicontrols). > > 2. Alternately, you can use a Matlab button uicontrol, and set the alpha symbol using HTML (alpha = &# 945;), as explained here: http://undocumentedmatlab.com/blog/html-support-in-matlab-uicomponents/ > > 3. Alternately, you can use a Java JLabel control, and set the alpha symbol using HTML, as explained here: http://undocumentedmatlab.com/blog/customizing-matlab-labels/ > > 4. Alternately, you can display the alpha symbol within an HTML-based edit-pane, as explained here: http://undocumentedmatlab.com/blog/gui-integrated-html-panel/ > > > > There are several other variants, but these should be sufficient for most use-cases. > > > > Yair Altman > > http://UndocumentedMatlab.com > > Dear Yair and Steve > > Thank you for taking time to help me. As I understand uicontrol cannot show symbols. In my example I have a GUI with a list box where different options can be choosed. The options are then shown in a textbox when I press the pushbutton. Can you come up with an example how to solve my problem soo symbols can be shown in the textbox?Yair can you show me two examples with option 1 and 2 that you mentioned or maybe one of the others? I do not have experience with Java programming. Hope the example under can shown what I want. > > function test6() > > > % global vectorOfValues > % vectorOfValues = []; > > f=figure('name','test',... > 'numbertitle','off',... > 'menubar','none',... > 'color',[0.85, 0.85, 0.85],... > 'units','normalized',... > 'position',[0 0.1 0.95 0.87]); > > col=get(f,'color'); > > uicontrol('style','pushbutton',... > 'units','normalized',... > 'position',[0.325 0.1 0.10 0.04],... > 'string','Table',... > 'backgroundcolor',col,... > 'callback',@go99709); > > > > > ht2=uicontrol('style','text',... > 'units','normalized',... > 'position',[0.5, 0.3,0.4 0.5],... > 'backgroundcolor',[0.95, 0.95, 0.95],... > 'string','',... > 'fontsize',15); > > hlb576=uicontrol('style','listbox',... > 'units','normalized',... > 'position',[0.3 0.3 0.15 0.1],... > 'string',{'y11';'y22'}); > > function go99709(varargin) > > choice=get(hlb576,'value'); > if choice==1 > y6=[10 20 30 40] > y66=[1 2 3 4] > set(ht2,'string',sprintf('%.0f \\circ %.0f min\n',[y6';y66'])) > elseif choice==2 > set(ht2,'string','Car price') > end > end > end > > Best Regards > > Hans Anybody that can help me? I would really appreciate if anybody could come up with a modified edition of the example I have shown above. Best Regards Hans |