How to calculate the value of polynomial value for 150 coefficient.It is not possible to use polyval function.

1 回表示 (過去 30 日間)
I try this
for k=1:150
x=x1(k);
fprintf('============')
sum1=0;
b=0;
for i=1:2
b=b+B1(i)*power(x,i) ;
sum1=sum1+b;
end
final(i)=10000+sum1;
end

回答 (1 件)

Walter Roberson
Walter Roberson 2016 年 12 月 25 日
final = 10000 + B1(1) * x1(1:150) + B1(2) * x1(1:150).^2 ;
This can be written as
final = 10000 + B1(1) * x1 + B1(2) * x1.^2 ;
if x1 is exactly 150 items long.
  5 件のコメント
John D'Errico
John D'Errico 2016 年 12 月 25 日
編集済み: John D'Errico 2016 年 12 月 25 日
It will "work". It will produce complete garbage. But that is a completely different issue, as you well know.
Walter Roberson
Walter Roberson 2016 年 12 月 26 日
Yep. And unless the user happens to have pure integer coefficients and pure integer x values, it is not clear that they could meaningfully get anything other than garbage (at least not with less than 1800 decimal places results.)

サインインしてコメントする。

カテゴリ

Help Center および File ExchangePolynomials についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by