MATLAB: Are the MuPAD commands from the Symbolic Math Toolbox 5.9 (R2012b) and later not working in the MATLAB Command Window or Editor

Symbolic Math Toolbox

I am having difficulties trying to get my symbolic math code to work in the MATLAB Command Window. Below are some typical error messages I observe:
1) When trying to invert a matrix:
A := array(1..2, 1..2, [[1, 2], [3, PI]])
numeric::inverse(A)
I get this error message:
Error: File: Untitled.m Line: 2 Column: 9
Unexpected MATLAB operator.
2) When I try to create an ellipse:
>> ellipse := plot::Ellipse2d(3, 1, [1, 1]);
I get this error message:
Undefined function 'ellipse' for input arguments of type 'char'.
3) When I try to use the following command:
>> Graph::createCompleteGraph(3)
I get this error message:
Graph::createCompleteGraph(3)
Error: Unexpected MATLAB operator.
4) When trying to solve an equation using the Symbolic Math Toolbox SOLVE function:
>> syms x
>> solve(x^4 - 5*x^2 + 6*x = 2, x)
I get this error message:
solve(x^4 - 5*x^2 + 6*x = 2, x)
Error: The expression to the left of the equals sign is not a valid target for an assignment.
5) When computing a partial fraction decomposition for symbolic x:
>> syms x
>> partfrac(x^2/(x^3 - 3*x + 2))
I get this error message:
Undefined function 'partfrac' for input arguments of type 'sym'.
6) When computing an integral:
>> int(1/x/ln(x), x = exp(1)..exp(2))
I get this error message:
int(1/x/ln(x), x = exp(1)..exp(2))
Error: The expression to the left of the equals sign is not a valid target for an
assignment.

Best Answer

The reason you are seeing these errors is that you are trying to use MuPAD functions and syntax in the MATLAB Desktop (Command Window, Editor).
For example, ":=", "::" and ".." are not valid operators in MATLAB, but they are, however, valid in the MuPAD language. "=" does not have the same meaning in MuPAD and MATLAB, and its use in example 4 above is erroneous.
Likewise, while functions such as "array", "numeric::inverse", "plot::Ellipse2d", "Graph::createCompleteGraph" and "partfrac" are available in MuPAD, they do not exist in the MATLAB interface of Symbolic Math Toolbox.
Functions such as "solve" or "int" are available in both, but use different syntaxes, which is why the examples above error out: they are using MuPAD-specific syntax in the MATLAB Command Window.
When looking at a documentation page such as that for "numeric::inverse":
<http://www.mathworks.com/help/symbolic/mupad_ref/numeric-inverse.html>
You can determine that this command belongs to MuPAD in several ways:
a) the link above contains "mupad_ref";
b) the "breadcrumbs" just under the search bar include "MuPAD";
c) the page appears under the MuPAD section if you expand the "Contents" pane on the left;
d) the examples use formatting that is specific to the MuPAD notebook (see below).
MuPAD code should be executed in a MuPAD Notebook, which can be started from the command line by typing:
>> mupad
Besides using the documentation, Code Analyzer warnings and MATLAB Editor syntax highlighting will often clarify whether a command or particular syntax in your MATLAB code is in fact MuPAD-specific. Examples of this are "red squiggles" (indicating syntax errors) or entire lines of purple-colored code (indicating characters that are treated as strings, as opposed to commands, variables, numbers, and so on).