(Good Ol') Error in MuPAD command: DOUBLE cannot convert...
Show older comments
I know many a question like this has been asked before, but the cases that I've seen are more complicated and the answers appear to pertain only to the specific cases.
syms x
f(x) = [x x^2; x^3 x^4];
f(2)
The output is supposed to be as follows, but instead I get the error message. How come? And how do I fix it? Thanks.
ans =
[ 2, 4]
[ 8, 16]
4 Comments
Marc
on 12 Nov 2013
I get an error when I copy your code into "one" line in the command line...
>> syms x
f(x) = [x x^2; x^3 x^4];
f(2)
The following error occurred converting from sym to double:
Error using mupadmex
Error in MuPAD command: DOUBLE cannot convert the input expression into a double array.
If the input expression contains a symbolic variable, use the VPA function instead.
When I go line for line...
>> clear all
>> syms x
>> f(x) = [x x^2; x^3 x^4];
>> f(2)
ans =
[ 2, 4]
[ 8, 16]
No idea why??
Walter Roberson
on 12 Nov 2013
f already existed as a numeric array. f(x) then fails to convert the symbol x to an array of numbers to use as indices into f.
Tom V
on 12 Nov 2013
Walter Roberson
on 12 Nov 2013
Which MATLAB version are you using? The ability to define a function with that syntax is relatively new. Before that, the conversion to double error would occur while trying to create an index, and that would not depend on whether f already existed or not.
Answers (0)
Categories
Find more on Common Operations in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!