Greek letters, subscripts, and superscripts in the editor
Ältere Kommentare anzeigen
Why in the world is matlab's editor not capable of dealing with greek letters, subscripts and superscripts? I cannot possibly be the only one who would rather see the greek letter for pi instead of the word. Really, though, it would just be nice if my equations in the editor could more closely resemble the real thing..
c'mon... physics, engineering, math... everyone uses greek letters and subscripts/superscripts! Why can't matlab's editor?
1 Kommentar
David Sherwood
am 27 Aug. 2020
I agree. I would like to use Greek letters/symbols in comments, '% ...'. They can be pasted in fine and printed out fine but the editor does not save them! When you go back to your script after closing/saving it, the Greek letter/symbols appear as '?'. Is there a way around this other than "publishing" or LaTEX?
Antworten (1)
Sean de Wolski
am 9 Sep. 2011
Sure you can, you just have to use LaTeX. See the example in:
doc
Matlab>User Guide>Desktop Tools>Publishing M-Files>Formatting Mfile Comments:
- Including Inline LaTeX Math Symbols in M-Files for Publishing
- Including Blocks of LaTeX Math Symbols in M-Files for Publishing
7 Kommentare
Clint Johnson
am 9 Sep. 2011
Sean de Wolski
am 9 Sep. 2011
So you want to be able to name a variable phi? I (and many others) don't see any advantage to that over a well named English word as a variable. If you want to be able to do it, use MathCAD - it's designed for that purpose.
Walter Roberson
am 9 Sep. 2011
The printable US-ASCII characters that MATLAB does not use as operators or punctuation are:
" (34)
# (35)
$ (36) -- pound sign in UK-ASCII
_ (95) -- valid in identifiers except as first character
` (96)
That is a maximum count of 5, which is not even close to "60 or so".
The MATLAB "name space of identifiers" is identical to the C "name space of identifiers", with the exception that C allows variable names to begin with underscore. Thus, every MATLAB identifier name may be used unchanged in C (unless it happens to match a C keyword), and MATLAB is given a bit of freedom to generate identifiers for use in communicating with C without worrying about accidentally conflicting with a user identifier.
MATLAB is currently defined in such a way that only characters in strings or comments can be outside of the US-ASCII character set. It is not unreasonable in the modern era to call for it to allow other languages, but however that was done would require encoding the characters so that if the program were taken to a system with a different character set, that the program would continue to run unchanged (just perhaps a bit uglier to read.) This includes the requirement that a full multilingual program must run (and be editable) in plain text, and that the encodings must be compatible with C/C++ . And _ideally_, the encoding of a character outside the US_ASCII range should have a readable name, such as _Phi__alpha_B3 (e.g., underscore before and after each entity name.) Now comes a question: should _Phi__alpha_B3 be considered an identifier of length 16, or should it be considered an identifier of length 4, for the purposes of the 63 character identifier limit (63 is the length of identifier that POSIX promises will be recognized for external linkage, so it is not just an arbitrary number chosen by TMW.)
Clint Johnson
am 12 Sep. 2011
Walter Roberson
am 12 Sep. 2011
Clint, you specifically talked about unused ASCII characters, but ASCII only uses the range 0 to 127. Characters such as alt-170 are not ASCII characters.
ASCII is a standard. Character encodings these days are standards, and characters cannot simply be inserted in to convenient places without a lot of compatibility trouble. In modern standards, the basic Greek characters run from position 880 to 1023. However, equations in math and physics are not actually written with Greek: they are written with glyphs that are derived from Greek. For example, in formula, the Greek-like glyphs are usually in italics, and that is considered separate symbols from the corresponding Greek characters. Then there are issues about how to deal with hats and dots and so on. The micro symbol appears multiple times in the standards depending on context.
I suggest you review http://unicode.org/reports/tr25/tr25-8.html
Quite a bit of my MATLAB work is from the command line, often with graphics (and the MATLAB editor) not available. The difficulty of entering characters *does* matter to me.
Maple deals with the problem by allowing HTML-like named characters that are rendered symbolically if you are using one of the Maple GUIs, but which are stored internally as ASCII and so can be worked with in plain text.
Clint Johnson
am 12 Sep. 2011
Walter Roberson
am 12 Sep. 2011
Sure, some programs (I mentioned Maple already) allow "2D notation" in entering equations. It is often a PITA to actually use or understand.
For example, in that input mode, Maple does translate underscore in to subscripts. Which is a nuisance if you have underscores in your variable names that do _not_ indicate subscripts. And when you see x with the subscript 1, does that indicate index 1 in to the vector x, or does it indicate the variable whose name is x subscript 1 ?
Or try something simple like x^2+1 . The ^ triggers superscript mode, so your cursor rises above the x, you type in the 2, you type in the +1 ... and you notice that you now have what is logically equivalent to x^(2+1) because the 2D math entry mode doesn't know that you finished entering the superscript. So after the 2, you have to press some key combination to indicate the end of superscript mode, and then the program tries to guess about where you want to be next ... usually getting it wrong, so a lot of the time you end up having to click to get where you want. And then you probably have to click again a few times because it highlighted an entire term instead of understanding that you are trying to position after the term...
So then you want to enter 1/2/3 (i.e., ((1/2)/3) . But the program helpfully went in to divisor mode when you typed the first / and so you end up with the equivalent of (1/(2/3))... and so on.
And Pi? You better pull it out of a character-table menu, since there are at least 6 different _kinds_ of Pi that are used as mathematical symbols with different meanings.
With regards to your claim that "And geometry certainly does use greek characters." -- did you read down to the "Semantic Distinctions" paragraph of section 2.2 of the technical report I referenced? As far as mathematics papers are concerned, a sans-serif bold italic "alpha" is *not* the same symbol as a Greek alpha.
The international standards encode characters. Characters are entities that retain their identity no matter how they are drawn. For example, an italic "k" in the Helvetica font is the same _character_ as a bold "k" is the Century New Schoolbook font, even though they look different. Mathematics and physics, though, impart meaning to the different looks of the symbols. When the meaning of a symbol depends on the way it looks, then one is not referring to characters: one is referring to glyphs. See http://en.wikipedia.org/wiki/Glyph for an example of 9 different glyphs associated with the lowercase character "a". Mathematics and physics (including geometry) prescribe different meanings to the different glyphs.
"No defensible reason" -- you would be surprised how much work it is to get the representations you propose to work properly. The effort is measured in person-decades. As you do not know or care about the details of ASCII, it seems fairly likely that you have not completed any of the "double-bend" exercises in Knuth's manuals on TeX and thus do not know how complicated some of the practical aspects get.
Kategorien
Mehr zu Labels and Annotations finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!