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

1 次查看(过去 30 天)
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 ?

请先登录,再进行评论。

回答(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 个评论
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