(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!