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

1 visualización (últimos 30 días)
majed alharbi
majed alharbi el 19 de Sept. de 2020
Comentada: Rena Berman el 8 de Oct. de 2020
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 comentarios
Stephen23
Stephen23 el 19 de Sept. de 2020
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 el 8 de Oct. de 2020
(Answers Dev) Restored edit

Iniciar sesión para comentar.

Respuestas (1)

Alan Stevens
Alan Stevens el 19 de Sept. de 2020
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 comentarios
majed alharbi
majed alharbi el 19 de Sept. de 2020
Walter Roberson
Walter Roberson el 19 de Sept. de 2020
Editada: Walter Roberson el 19 de Sept. de 2020
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.

Iniciar sesión para comentar.

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by