polyval doesn't recognise input as numeric value
1 回表示 (過去 30 日間)
古いコメントを表示
Paris Pasqualin
2020 年 11 月 1 日
コメント済み: Paris Pasqualin
2020 年 11 月 1 日
Hello to all,
I want to create a loop where a value x is calculated through interpolation. In the first run "x = polyval(p,y);" works fine. In the end of the first run I get:
x =
48845.957126841025088289460260046
In the second run where x has changed, even though x is a number, polyval gives me an error saying "Error using filter Invalid data type. Input arrays must be numeric or logical.". Putting the value manually doesn't give the error.
Has anyone faced this error before?
Best regards,
Paris Pasqualin
2 件のコメント
KSSV
2020 年 11 月 1 日
It will work for all the cases if the input is double. You need not to use a loop, you can input x as an array. Show us how was x which threw error.
採用された回答
Walter Roberson
2020 年 11 月 1 日
the length of the output tells us that x is symbolic not double precision. polyval cannot work on symbolic.
(polyval is easy to code for symbolic use if you have not used centering and scaling)
4 件のコメント
John D'Errico
2020 年 11 月 1 日
編集済み: John D'Errico
2020 年 11 月 1 日
If you used vpasolve, then you used a symbolic toobox tool. The result will not be a double or single precision number, but a floating point SYMBOLIC number. polyval CANNOT use that value. Polyval works ONLY on singles or doubles. Just because something looks like a number does not make it a number as it is stored in MATLAB. For example, the string '1.2345' may look like a number, but that does not make it a number, then usable by polyval.
You can convert the output of vpa/vpasolve to a double using double.
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!