invalid subscript: physics and commutators in maple17 - maple

I tried the following based on the first example in the maple 17 help for "Physics[Commutator]". anybody know what's wrong?
with(Physics);
Setup(mathematicalnotation = true);
e1:=[Z[1],Z[2]][-];
Error, invalid subscript
Typesetting:-mambiguous(e1Assign(Z[1]commaZ[2])[
Typesetting:-mambiguous(Typesetting:-mstyle( - ,
executable = "false", mathcolor = "#909090",
mathvariant = "normal"),
Typesetting:-merror("invalid subscript"))])

Your third line is not the third input line from start of the Examples section of the help-page for the Physics[Commutator] command in Maple 17.
Indeed, you third line of code does not match any input on that help-page.
When the examples on the Physics[Commutator] help-page are viewed in 1D mode (in the Maple Standard GUI's Help system) the input will appear as red plaintext. When toggled so that the input for the examples is viewed in 2D mode then the input will appear as black 2D typeset math. In either case the output of the help examples will appear as blue 2D typeset math.
In the Std GUI there is an icon at the top of the Help window which allows you to toggle display of the input mode between red 1D and black 2D. In the Online Help the input is shown only as black 2D typeset math.
Your third line of code is not a valid syntax for the command in question. You appear to have incorrectly tried (either by typing or pasting) to use the literal form of the blue 2D typeset math output from the third statement on that help-page.
In other words, it seems as if you might be trying to use the echoed form of the displayed blue output as syntax for input. That wouldn't work. (It doesn't work generally in Maple.) If you want to run the code, then copy the input lines, not the output lines.
Note also that on that help-page in question the very next line of commentary explains that the output above it is just an artefact of a specialized display mechanism, displaying a shorthand to represent the structure.

Related

Adjusting graphical LaTeX text size in Matlab

I am trying this example:
http://www.mathworks.com/help/symbolic/latex.html
Let's say I wanted to resize those labels. How? I can't figure out any LaTeX code, and 'fontsize' does not do the trick.
This hits a sore spot when it comes to Matlab's support for (or use of) Latex. The normal font-size commands from Latex aren't available. (In Latex normally you'd just say \Large{Text ... $x$} or even \normalsize ....)
To do this in a Matlab plot you can add fontsize spec at the end
title(['For $x$ and ...'], 'Interpreter', 'latex', 'fontsize', 14)
For more discussion and how to change font type as well see this post. Note that there are not so many fonts readily available in Matlab. To preserve sanity I'd keep this kind of tweaking to the minimum.
There is another method that will work anywhere in Matlab where you can use Latex -- in any text, in the middle of a string, etc: You can drop to Latex's lower level font specification.
title(['\fontsize{15}{0}\selectfont For $x$ and ...'], 'Interpreter', 'latex')
The first command \fontsize{}{} specifies the font, the second one \selectfont actually changes it for the rest of the text. When you want to switch to a different font, even mid-string, you again issue \fontsize{12}{0}\selectfont and you have that font size after that point. The only thing you need to change is the size (I used 15 and 12 as examples), the rest is boilerplate (for this purpose).
See what these things mean and more discussion in this post. For far more detail on fonts in Matlab see this article. For how to change fonts across the whole document see this post.
There are yet other ways but it gets progressively trickier and this should be enough. Probably the best advice is to set it once for the whole document. That also makes sense typesetting-wise.
Note. The font command of the second example must be given outside of math mode. Latex has two major modes, text and math. To make it go to 'math mode', where it processes everything as it were math symbols, you put a $, or $$. (There are yet many other ways, but in Matlab's strings this is all you'll ever use.) When you want it to go back to typesetting text normally, you end math mode with another $, or $$. All math is in between $...$, everything else is normal text.
This is some text, now typeset some math: $y = x^2$ ... back to text.
The font commands do not work in math mode but need be given outside the $...$. They will apply to any following math as well. In a plot command we'd say
ylabel(['\fontsize{16}{0}\selectfont $\dot{x}$'], 'interpreter','latex');
Here is the line that worked:
ylabel('$x_e, x_c$', 'interpreter','latex', 'fontsize', 32);
Obviously, between the dollar signs can be whatever appropriate LaTeX expression desired.

Infinity symbol does not show in Matlab plot

I'm trying to include the infinity symbol ∞ in my axis label (e.g. the expression δ∞), so I typed \delta_{\infty}. However, I only see the delta symbol δ but the infinity symbol is portrayed as a subscripted black diamond with a question mark inside.
The interpreter is set to Tex and I tried different fonts with other symbols. The greek letters seem to be working but other symbols like \clubsuit (♣) don't. Do I need to make any other changes to the settings?
From this I make up that you should use LaTeX as the interpreter, rather than TeX:
http://www.mathworks.com/matlabcentral/answers/21984
If you're still looking for answer, it works for you: \delta_\infty = δ∞

Line detection using PIL

Given an image consisting of black lines (a few pixels wide) on white background, what is a good way to find the coordinates along the the lines, say for every 10th pixel or so? I am considering using PIL for the task, but other python or java-based libraries would also be OK.
Ideally the coordinates would point to the middle of the line, but as the lines are narrow, it's enough that they point somewhere inside the line.
A very short line or a point should be identified with at least one coordinate.
Usually, Hough transformation is used to find lines. It gives you the parameters describing the line (which can be transformed easily between different representations), and you can sample this function to get your sample points. See http://en.wikipedia.org/wiki/Hough_transform and https://stackoverflow.com/questions/tagged/hough-transform+python
I only found this http://coding-experiments.blogspot.co.at/2011/05/ellipse-detection-in-image-by-using.html implementation in python, which actually searches for ellipses.

How to get coordinates of recognized characters

I have a very simple OCR app based on Tesseract. After the recognition
step, I also provide a user verification step that allows correction
in case OCR is wrong. To improve the user interface, I plan to draw a
rectangle on top of the OCR-ed character on the original input image,
and put it side by side with the OCR output. To get to that, I need
the coordinate of the recognized characters.
I tried something like this but it seems to give me gibberish:
ETEXT_DESC output;
tess->Recognize(&output);
text = tess->GetUTF8Text();
Now if I access output->count, it gives me some value above 10,000,
which is obviously wrong because the whole image only has 20 or so characters.
Am I on the right track? Can I have some direction please?
Maybe it's helpful to get the coordinates of the boxes.
Try the executable of tesseract. Use the command
"tesseract.exe [image] [output] makebox"
Afterall you get the coordinates of each character, one per row. Then you are able to compare.
The tesseract executable has an option hocr to output recognized characters and their coordiantes in html format. To get this programmatically, the FAQ says to refer to baseapi.h.

Matlab: Adding symbols to figure

Below is the user interface I have created to simulate LDPC coding and decoding
The code sequence is decoded iteratively by passing values between the left and right nodes through the connections.
The first thing it would be good to add in order to improve visualization is to add arrows to the connections in the direction of passing values. The alternative is to draw a bigger arrow at the top of the connection showing the direction.
Another thing I would like to do is displaying the current mathematical operation below the connection (in this example c * H'). What I don't know how to do is displaying special characters and mathematical symbols and other kinds of text such as subscript and superscript in the figure (for example sum sign and subscript "T" instead of sign ="'" to indicate transposed matrix).
I would be very thankful if anyone could point to any useful resources for the questions above or show the solution.
Thank you.
To add arrows, you can either use the built-in QUIVER, or, for more options, ARROW from the file exchange. Both of these have to be plotted into axes, so if you want a big arrow on the top, you have to create an additional set of axes above the main axes.
As far as I know, you cannot use TeX or LaTeX symbols in text uicontrols. However, you can use them in axes labels. Thus, I suggest that you add an XLabel to the axes, for example
xlabel('\sigma c*H_T')
or (note the $-signs required for LaTeX)
xlabel('$\sum c*H_T$','interpreter','latex')
EDIT
I hadn't mentioned the use of text (as suggested by #gnovice and #YYC) because I thought it wasn't possible to place text outside of the axes. It turns out that I was wrong. text(0.5,-0.2,'\Sigma etc.') should work fine as well. I guess the only advantage of using 'xlabel' would be that you can easily add and position the axes label during GUI creation.
In regards to the 1st question, annotation (http://www.mathworks.com/access/helpdesk/help/techdoc/ref/annotation.html) might be an alternative solution.
In regards to the 2nd question, try text property in Matlab Help.
Search "Character Sequence" for the special characters; search "Specifying Subscript and Superscript Characters" for the subscript and superscript.
For drawing the arrow, I would go Jonas' suggestion arrow.m by Erik Johnson on the MathWorks File Exchange. It's the easiest way I've found to create arrows in figures.
For creating text with symbols, you can use the function TEXT. It lets you place text at a given point in an axes, and you can use the 'tex' (default) or 'latex' options for the 'Interpreter' property to get access to different symbols. For example, this places the text you want at the point (0,0) using 'latex' as the interpreter:
hText = text(0,0,'$\sum c*H_T$','Interpreter','latex');
The variable hText is a handle to the text object created, which you can then use with the SET command to change the properties of the object (string, position, etc.).