Index exceeds the number of array elements (1).

1 回表示 (過去 30 日間)
Heya :)
Heya :) 2020 年 9 月 18 日
編集済み: Heya :) 2020 年 10 月 16 日
Can anybody please help why I am getting this error. I am unable to figure out what I am doing wrong in this code.
I am getting this error [ndex exceeds the number of array elements (1).
Error in trial (line 132)
xhat(i)= d1+d2*x_rec(i-1)+d3*y_rec(i-1)+d4*x_rec(i-1)*y_rec(i-1)+d5*x_rec(i-1)^2+d6*y_rec(i-1)^2+d7*x_rec(i-1)^2*y_rec(i-1)^2+d8*x_rec(i-1)^2*y_rec(i-1)+d9*x_rec(i-1)*y_rec(i-1)^2+d10*x_rec(i-1)^3+d11*y_rec(i-1)^3+d12*x_rec(i-1)^3*y_rec(i-1)+d13*x_rec(i-1)*y_rec(i-1)^3+d14*x_rec(i-1)^3*y_rec(i-1)^2+d15*x_rec(i-1)^2*y_rec(i-1)^3+d16*x_rec(i-1)^3*y_rec(i-1)^3;
>> ]

採用された回答

KSSV
KSSV 2020 年 9 月 18 日
Repalce with this the for loop.
for i=2:length(x_rec)
xhat(i)= d1+d2*x_rec(i-1)+d3*y_rec(i-1)+d4*x_rec(i-1)*y_rec(i-1)+d5*x_rec(i-1)^2+d6*y_rec(i-1)^2+d7*x_rec(i-1)^2*y_rec(i-1)^2+d8*x_rec(i-1)^2*y_rec(i-1)+d9*x_rec(i-1)*y_rec(i-1)^2+d10*x_rec(i-1)^3+d11*y_rec(i-1)^3+d12*x_rec(i-1)^3*y_rec(i-1)+d13*x_rec(i-1)*y_rec(i-1)^3+d14*x_rec(i-1)^3*y_rec(i-1)^2+d15*x_rec(i-1)^2*y_rec(i-1)^3+d16*x_rec(i-1)^3*y_rec(i-1)^3;
end
  1 件のコメント
Heya :)
Heya :) 2020 年 9 月 18 日
Thank you for the response. Now, its giving me this error.
Unrecognized function or variable 'xhat'.
Error in trial (line 132)
PE_x(count)=PE_x(count)+(xhat(i)-x(i))^2;

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

その他の回答 (1 件)

Alan Stevens
Alan Stevens 2020 年 9 月 18 日
You should put
x_rec = zeros(1000,1);
y_rec = zeros(1000,1);
just before
x_rec(1)=x(1);
y_rec(1)=y(1);
  1 件のコメント
Heya :)
Heya :) 2020 年 9 月 23 日
Thank you !

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

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by