Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Greek letters in strings

Subject: Greek letters in strings

From: Tim Archer

Date: 17 Oct, 1997 10:41:55

Message: 1 of 14


Is is possible to use Greek letters in strings, say for graph labels and
uimenu menus? I'm particularly interested in mu and sigma. Thanks for any
advice.


Tim

Subject: Greek letters in strings

From: behr@cs.tu-berlin.de (Thomas Behr)

Date: 23 Oct, 1997 00:23:51

Message: 2 of 14

"Tim Archer" <tarcher@black.ug.cs.su.oz.au> wrote:

>
>Is is possible to use Greek letters in strings, say for graph labels and
>uimenu menus? I'm particularly interested in mu and sigma. Thanks for any
>advice.
>
>
>Tim
>

The only way to get greek letters that I know is in axes-objects (e.g.
labels and titles) using TeX-commands.

 For example:
set(get(h,'Title'),...
'String',('\itAe\rm^{-\alpha\itt\rm}sin\beta\it{t} \alpha<<\beta'))
set(get(h,'Xlabel'),'String','Time \musec.')
set(get(h,'YLabel'),'String','Amplitude')
The backslash character \ precedes all TeX character sequences.

... and in the text()-comand

t = 0:900;
plot(t,0.25*exp(-0.005*t))

text(300,.25*exp(-0.005*300),...
'\bullet\leftarrow\fontname{times}0.25{\ite}^{-0.005{\itt}} at {\itt}
= 300');

But this works only in axes-related objects.

I'm looking for a solution for a normal text-uicontrol-object too.

Thomas

Subject: Greek letters in strings

From: cwhite

Date: 24 Oct, 1997 10:42:29

Message: 3 of 14

> Styled Text Toolbox

I don't know why the address didn't "go through," but here it is again

ftp://ftp.mathworks.com/pub/contrib/graphics/stextfun

Subject: Greek letters in strings

From: cwhite

Date: 24 Oct, 1997 10:36:04

Message: 4 of 14


--------------AC80A46A763F10EB8346A30C
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Tim Archer wrote:

> Is is possible to use Greek letters in strings, say for graph labels
> and uimenu menus? I'm particularly interested in mu and sigma. Thanks
> for any advice.
>
> Tim

Please excuse me if the following is too trivial a solution:

text(x_position,y_position,'abcdefghijklmnopqrstuvwxyz','FontName','Symbol')

I also wonder if perhaps the following would help you:

Styled Text Toolbox
Version 3.2b, 10 March 1997
Copyright 1995-1997 by Douglas M. Schwarz. All rights reserved.
schwarz@kodak.com

___________________________________________________________________________

The most recent version of the Styled Text Toolbox should be available
from



___________________________________________________________________________

Introduction.

The Styled Text Toolbox is a collection of tools which enables the user
to mix fonts, text styles and mathematical constructs (superscripts,
subscripts, integrals, special math characters, etc.) in a single styled
text object.

Features:

* Internal "command language" similar to LaTeX
* Text properties applicable on a per character basis: FontName,
FontSize,
      FontWeight, FontAngle, Color
* Text properties applicable to entire styled text object: EraseMode,
      HorizontalAlignment, Position, Rotation, Units, VerticalAlignment,
      ButtonDownFcn, Clipping, Interruptible, Visible
* Superscripts and subscripts
* Greek letters using LaTeX names
* Simulated italic (slanted) Greek letters possible
* Many other characters from Symbol font available using LaTeX names
* Some non-LaTeX characters available
* Diacritics above any character
* Fractions, roots, integrals, summations and products
* Kerned output using kern pairs from Adobe Font Metric files
* All 35 standard fonts supported (the ones built-in to most PostScript
      printers), except on Student Edition where New Helvetica Narrow is
      not supported so as not to exceed 8192 element limit.
* Styled text xlabels, ylabels, zlabels and titles
* Styled text legends and text boxes
* Positions specifiable in 2-D or 3-D coordinates
* Does not require WYSIWYG mode for correct printing
* Fine adjustment of character positions possible
* Syntax nearly the same as that of the built-in text function
* No hard-coded defaults or assumptions
* Platform independent


--------------AC80A46A763F10EB8346A30C
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<HTML>
Tim Archer wrote:
<BLOCKQUOTE TYPE=CITE>Is is possible to use Greek letters in strings, say
for graph labels and uimenu menus? I'm particularly interested in mu and
sigma.  Thanks for any advice.

<P>Tim</BLOCKQUOTE>
Please excuse me if the following is too trivial a solution:

<P>text(x_position,y_position,'abcdefghijklmnopqrstuvwxyz','FontName','Symbol')

<P>I also wonder if perhaps the following would help you:

<P>Styled Text Toolbox<BR>
Version 3.2b, 10 March 1997<BR>
Copyright 1995-1997 by Douglas M. Schwarz.  All rights reserved.<BR>
schwarz@kodak.com<BR>
<BR>
___________________________________________________________________________<BR>
<BR>
The most recent version of the Styled Text Toolbox should be available
from<BR>
<BR>
 <ftp://ftp.mathworks.com/pub/contrib/graphics/stextfun><BR>
<BR>
___________________________________________________________________________<BR>
<BR>
Introduction.<BR>
<BR>
The Styled Text Toolbox is a collection of tools which enables the user
to mix fonts, text styles and mathematical constructs (superscripts, subscripts,
integrals, special math characters, etc.) in a single styled text object.<BR>
<BR>
Features:<BR>
<BR>
* Internal "command language" similar to LaTeX<BR>
* Text properties applicable on a per character basis:  FontName,
FontSize,<BR>
      FontWeight, FontAngle, Color<BR>
* Text properties applicable to entire styled text object:  EraseMode,<BR>
      HorizontalAlignment, Position, Rotation,
Units, VerticalAlignment,<BR>
      ButtonDownFcn, Clipping, Interruptible,
Visible<BR>
* Superscripts and subscripts<BR>
* Greek letters using LaTeX names<BR>
* Simulated italic (slanted) Greek letters possible<BR>
* Many other characters from Symbol font available using LaTeX names<BR>
* Some non-LaTeX characters available<BR>
* Diacritics above any character<BR>
* Fractions, roots, integrals, summations and products<BR>
* Kerned output using kern pairs from Adobe Font Metric files<BR>
* All 35 standard fonts supported (the ones built-in to most PostScript<BR>
      printers), except on Student Edition where
New Helvetica Narrow is<BR>
      not supported so as not to exceed 8192 element
limit.<BR>
* Styled text xlabels, ylabels, zlabels and titles<BR>
* Styled text legends and text boxes<BR>
* Positions specifiable in 2-D or 3-D coordinates<BR>
* Does not require WYSIWYG mode for correct printing<BR>
* Fine adjustment of character positions possible<BR>
* Syntax nearly the same as that of the built-in text function<BR>
* No hard-coded defaults or assumptions<BR>
* Platform independent
<BR> </HTML>

--------------AC80A46A763F10EB8346A30C--

Subject: Greek letters in strings

From: Paul Skoczylas

Date: 24 Oct, 1997 12:55:16

Message: 5 of 14

cwhite wrote:
>
>text(x_position,y_position,'abcdefghijklmnopqrstuvwxyz','FontName','Symbol')
>

Well, that's great, but is there an easy way to make one character in
the string from the symbol font, and the rest from another font?

(BTW, The styled text toolbox is quite nice for many applications.
However, I, like the original poster in this thread, would like a neat,
simple solution to this problem; one which does not require a large
toolbox and special printing commands.)

-Paul

Subject: Greek letters in strings

From: Nabeel Azar

Date: 24 Oct, 1997 15:20:05

Message: 6 of 14

> >text(x_position,y_position,'abcdefghijklmnopqrstuvwxyz','FontName','Symbol')
>
> Well, that's great, but is there an easy way to make one character in
> the string from the symbol font, and the rest from another font?

Sure; if you have MATLAB 5, try this:

text(x_pos,y_pos,'This \omega character is a Greek character')
text(x_pos,y_pos,'Two more letters are \alpha and \beta')

For more info, open up the helpdesk and click on "Handle Graphic Objects". Then
click on "Text" and you'll see a list of text properties. Click on "String" in
the left frame, and it will take you to a section of code where the various TeX
symbols and modifiers usable in MATLAB are described.

Have fun,

Nabeel


--

 ____________________________
| The MathWorks, Inc. |
| Nabeel Azar |
| Technical Support Engineer |
| nabeel@mathworks.com |
 ----------------------------

Subject: Greek letters in strings

From: Thomas P. Krauss

Date: 27 Oct, 1997 13:27:03

Message: 7 of 14

cwhite wrote:
>
> Tim Archer wrote:
>
> Is is possible to use Greek letters in strings, say for
> graph labels and uimenu menus? I'm particularly interested
> in mu and sigma.  Thanks for any advice.
>
> Tim
>

A simple MATLAB 5 way: use backslash and type the name of
the greek letter you desire.

For example:

   title('\mu \sigma')

Subject: Greek letters in strings

From: behre@orbit.colorado.edu (Chip Behre)

Date: 27 Oct, 1997 13:54:50

Message: 8 of 14


>> Is is possible to use Greek letters in strings, say for
>> graph labels and uimenu menus? I'm particularly interested
>> in mu and sigma.  Thanks for any advice.
>>
>> Tim
>>
>
>A simple MATLAB 5 way: use backslash and type the name of
>the greek letter you desire.
>
>For example:
>
> title('\mu \sigma')

I've been following this thread hoping to see an easier way than manually
placing greek strings using the 'text' command. The major problem was
when trying to combine greek and non-greek letters. Well, here it is (and
it worked). Maybe I should have searched the manual, but I assumed that
there wasn't a convenient way. Thanks for enlightening me!

And to add to the above example, if you want a capital greek symbol use

   title('\Mu \Sigma')

--
-- Chip

Subject: Greek letters in strings

From: Tim Archer

Date: 28 Oct, 1997 01:37:10

Message: 9 of 14


Nabeel Azar <nabeel@mathworks.com> wrote

> > Well, that's great, but is there an easy way to make one character in
> > the string from the symbol font, and the rest from another font?
>
> Sure; if you have MATLAB 5, try this:
>
> text(x_pos,y_pos,'This \omega character is a Greek character')
> text(x_pos,y_pos,'Two more letters are \alpha and \beta')

Thanks - it seems the best solution to my problem is to persuade my maths
department to upgrade to version 5. I'm surprised this feature wasn't in
earlier versions.


Tim

Subject: Greek letters in strings

From: ehrhardt@euklid.math.tu-berlin.de (Matthias Ehrhardt)

Date: 28 Oct, 1997 09:29:38

Message: 10 of 14

In article <01bce343$19e6c780$53e14e81@client-83.stpauls.usyd.edu.au>, "Tim Archer" <tarcher@black.ug.cs.su.oz.au> writes:
|>
|> Nabeel Azar <nabeel@mathworks.com> wrote
|>
|> > > Well, that's great, but is there an easy way to make one character in
|> > > the string from the symbol font, and the rest from another font?
|> >
|> > Sure; if you have MATLAB 5, try this:
|> >
|> > text(x_pos,y_pos,'This \omega character is a Greek character')
|> > text(x_pos,y_pos,'Two more letters are \alpha and \beta')
|>
|> Thanks - it seems the best solution to my problem is to persuade my maths
|> department to upgrade to version 5. I'm surprised this feature wasn't in
|> earlier versions.
|>
|>
|> Tim
|>
In earlier Versions, say 4.2c you can proceed as follows:

Question: How to incorporate Greek letters in MATLAB graphs?

  Can anyone tell me how to write Greek letters delta, and omega with
  subscripts and superscripts (like in LaTex \delta_{1,n}) in xlabel, ylabel?

  Thanks in advance.

  Swapan Saha
  ssaha@iastate.edu

Answer from Doug Schwarz:

  My Styled Text Toolbox will do this. Use

      sxlabel('\delta_{1,n}')

  It is available from

  ftp://ftp.mathworks.com/pub/contrib/graphics/stextfun/

  Doug Schwarz
  Eastman Kodak Comapny
  schwarz@kodak.com

Answer from Carolyn Romano:

  There is also a way in MATLAB to use the hexidecimal equivalant of
  the Greek characters you want to incorporate.

  To place Greek characters in a plot, use the symbol font. For
  example:

        plot(1:10)
        text(5,5,'a*b','FontName','symbol')

  This will place "alpha times beta" in the plot.

  To determine the character mapping of the symbol font, use chart.m.
  chart.m displays the hexidecimal values for the characters in the
  symbol font. It is available via anonymous ftp.

    ftp://ftp.mathworks.com/pub/tech-support/library/graphics/chart.m

  Below is an example of how to use it:

        chart('symbol')
        % Find the last value for the characters you want to use.
        % For this example, I grabbed alpha(16) and beta(26).
        X_coordinate = [6 6]; % [alpha beta]
        Y_coordinate = [1 2]; % [alpha beta]
        a = setstr(16*X_coordinate(1)+Y_coordinate(1));
        b = setstr(16*X_coordinate(2)+Y_coordinate(2));
        str = [a,'*',b];
        plot(1:10)
        text(5,5,str,'FontName','symbol')
 
ciao, Matthias

_____________________________________________________________________________
| Matthias Ehrhardt | Phone : +49-030/314-79155 |
| Technical University Berlin | Fax : +49-030/314-25191 |
| Department of Mathematics | Email : ehrhardt@math.tu-berlin.de |
| Sekr. MA 6-2 | WWW: http://www.math.tu-berlin.de/~ehrhardt |
| Strasse des 17. Juni 136 | |
| D-10623 Berlin, Germany | |
-----------------------------------------------------------------------------
 

Subject: Greek letters in strings

From: Paul Fackler

Date: 28 Oct, 1997 17:39:20

Message: 11 of 14

A propos of the recent discussion of Greek letters in strings, in Matlab
5 the Tex-like solution does not work in UIControl strings. Has anyone
tried to put a Greek letter into a 'Text' style control and gotten it to
work?
--
***************
Paul L. Fackler Department of Agricultural and Resource Economics
North Carolina State University - Box 8109 Raleigh, NC, USA 27695
919-515-4535 paul_fackler@ncsu.edu

Subject: Greek letters in strings

From: damian@mathworks.com (Damian Packer)

Date: 29 Oct, 1997 01:39:38

Message: 12 of 14

Paul Fackler (paul_fackler@ncsu.edu) wrote:
> A propos of the recent discussion of Greek letters in strings, in Matlab
> 5 the Tex-like solution does not work in UIControl strings. Has anyone
> tried to put a Greek letter into a 'Text' style control and gotten it to
> work?

We haven't yet implemented Tex-like syntax for uicontrols, but this is
on our wish list for a future version.

In the meantime, you can use the symbol font to add greek characters
to a uicontrol, but that won't allow you to mix greek symbols with
other characters.

Hope this helps,

-Damian

--
  __ ______ Damian T. Packer
 / /|/ /\ The MathWorks, Inc.
/_/ /_____/ /| http://www.mathworks.com
| || ___ \/ | damian@mathworks.com
| || | / \ |/
| || |/__/ | /\ |\/| | /\ |\ |
| ||______/ /--\ | | | /--\ | \|
| | | _ _ _
| | / /\ / ` |/ |_ |_|
|_|/ /--\ \_, |\ |_ |\

Subject: Greek letters in strings

From: martl@sbox.tu-graz.ac.at (Matthias Fruehwirth)

Date: 29 Oct, 1997 09:32:47

Message: 13 of 14

Nabeel Azar (nabeel@mathworks.com) wrote:
:
: For more info, open up the helpdesk and click on "Handle Graphic Objects". Then
: click on "Text" and you'll see a list of text properties. Click on "String" in
: the left frame, and it will take you to a section of code where the various TeX
: symbols and modifiers usable in MATLAB are described.

Why did you guys at Mathworks hide this important piece of information in
such an acribic manner? It should be present at top at any page regarding
text output, *and* in the printed version of the manual at well!

Best regards
Matthias Fruehwirth
--
++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ Matthias Fruehwirth + martl@sbox.tu-graz.ac.at +
++++++++++++++++++++++++++++++++++++++++++++++++++++++

Subject: Mixing "normal" and Greek letters in MATLAB 4

From: cwhite

Date: 29 Oct, 1997 20:52:34

Message: 14 of 14

Paul Skoczylas wrote:

> cwhite wrote:
> >
> >
> ext(x_position,y_position,'abcdefghijklmnopqrstuvwxyz','FontName','Symbol')

> Paul Skoczylas wrote:
>
> Well, that's great, but is there an easy way to make one character in
> the string from the symbol font, and the rest from another font?

There is no wholly "clean" way to do this (that I know of in MATLAB
4.x). But using the "setstr" function and choosing an appropriate font
may provide an adequate work-around.

Try the following examples for a demonstration:

EDU» text(.05,.2,['here are some CHM14SS font symbols: ',setstr([131 32
136 32 152 32 153 32 162 32 167 32 168 32 169 32 182 32
198])],'FontName','CHM14SS')

EDU» text(.05,.8,['here are some Terminal font symbols: ',setstr([225
32 226 32 227 32 228 32])],'FontName','terminal')

These examples aren't intended to show all the Greek symbols present in
the Terminal and CHM14SS fonts.

If you choose a font that has both normal letters and at least a few
Greek symbols, then you might get what you need into one single text
string. It is awkward but it is the best way I know. Note that the
string must be formed as a vector with setstr interspersed where it is
needed.

I think that what would solve the problem for many of us is to have font
character maps that have all the normal characters and all Greek
symbols, plus a few more. I know of none like this.

I wrote the following m-file which should be of use to people needing
the setstr command:

function [asciiCharacter,index]=asciShow

% function [asciiCharacter,index]=asciShow
%
% With no output arguments, asciShow will make a character map table
associated
% with the current Command Window font. This would be useful for
obtaining
% special characters in any output or graph labeling since it is
necessary to
% know the associated index number.
%
% If you're using this for your graphs, you need to be sure that the
Command
% Windows font character map is the same as that of your figure's font
map.
% (The FONT doesn't have to be the same, just the CHARACTER MAP. For
example,
% "Courier New" and "Helvetica" have similar or identical character maps
but
% "Terminal" has significant differences.)
%
% See also: setstr

% Written by Gregory White
% (c) 8/28/97 All rights reserved

k=33:256;
k=reshape(k,32,7);

a=setstr(33:256);
a=reshape(a,32,7);

if nargout==0
   fprintf('\n')
   for m=1:32
      for n=1:7
         fprintf('%3.0f %s ',k(m,n),a(m,n))
      end
      fprintf('\n')
   end
   fprintf('\n')
end

if nargout>=1
   index(:,1)=k;
   asciiCharacter(:,1)=a;
end

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us