MATLAB: Do I receive different results from the DIFF function with char inputs between MATLAB 7.0 (R14) and MATLAB 6.5.1 (R13SP1)

answerchardiff()differentdoubler14symbolicSymbolic Math Toolboxwrong

For example, if I have the Symbolic Math Toolbox, and I execute the following command within MATLAB 6.5.1 (R13SP1):
diff('x^2')
I receive the expected result:
ans =
2*x
However, in MATLAB 7.0 (R14), I receive the unexpected result:
ans =
-26 -44

Best Answer

This bug has been fixed for Release 14 SP1 (R14SP1). For previous releases, please read below for any possible workarounds:
This has been verified as a bug within MATLAB 7.0 (R14) in the way some functions that are overloaded for char inputs convert the inputs to double precision values rather than symbolic expressions.
Currently, to work around this issue, convert your char expressions to symbolic expressions prior to supplying them to the DIFF function.