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

추가 답변 (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 CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by