How to plot y(n) over the range of 0<n<50. the equation given is y(n) = 1.97y(n-1) - y(n-2)

2 ビュー (過去 30 日間)
the conditions for y(0) =0 and y(1) =1. do i need to use while statement?

採用された回答

Star Strider
Star Strider 2017 年 9 月 16 日
Since the limits are stated, I would just use a for loop:
y(1) = 0;
y(2) = 1;
for n = 3:51
y(n) = 1.97*y(n-1) - y(n-2);
end
figure(1)
plot(0:50, y)
grid
  2 件のコメント
mrbond99
mrbond99 2017 年 9 月 16 日
thank you. this really help me
Star Strider
Star Strider 2017 年 9 月 16 日
As always, my pleasure!

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

その他の回答 (1 件)

Andrei Bobrov
Andrei Bobrov 2017 年 9 月 16 日
out = filter(1,[1,-1.97,1],[0,1,zeros(1,49)]);
plot(0:50,out);
  1 件のコメント
mrbond99
mrbond99 2017 年 9 月 16 日
I don't understand much on this coding but it give the same output as the answer above. Anyway,thank you

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

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by