(Good Ol') Error in MuPAD command: DOUBLE cannot convert...
显示 更早的评论
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 个评论
Marc
2013-11-12
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
2013-11-12
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
2013-11-12
Walter Roberson
2013-11-12
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.
回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Common Operations 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!