what y(2) ,y(3), y(4) , y(5) ,by using matlab ?

조회 수: 1 (최근 30일)
majed alharbi
majed alharbi 2020년 9월 19일
댓글: Rena Berman 2020년 10월 8일
y(0)=1 y(2)=5
y(n+2)=3y(n+1)-5y(n)
what y(2) ,y(3), y(4) , y(5) ,by using matlab ?
  댓글 수: 4
Stephen23
Stephen23 2020년 9월 19일
Original question by majed alharbi retrieved from Google Cache:
"what y(2) ,y(3), y(4) , y(5) ,by using matlab ?"
y(0)=1 y(2)=5
y(n+2)=3y(n+1)-5y(n)
what y(2) ,y(3), y(4) , y(5) ,by using matlab ?
Rena Berman
Rena Berman 2020년 10월 8일
(Answers Dev) Restored edit

댓글을 달려면 로그인하십시오.

답변 (1개)

Alan Stevens
Alan Stevens 2020년 9월 19일
You need to start with y(1) = 1, not y(0) = 1. Then with y(2) = 5, you can use a for loop:
for n=1:3, y(n+2) = 3*y(n+1)-5*y(n); end
  댓글 수: 3
majed alharbi
majed alharbi 2020년 9월 19일
Walter Roberson
Walter Roberson 2020년 9월 19일
편집: Walter Roberson 2020년 9월 19일
you did not loop like I suggested. You tried to vectorize.
The function can only be vectorized after a bunch of mathematical calculations to figure out the general form. I recommend looping, it is much easier.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by