finding nth value of formula with conditions

1 次查看(过去 30 天)
hello,
can u guys please help me finding nth value by using the next formula:
a(0)=2
a(1)=3
a(n)=(1-a(n-1))/a(n-1) +a(n-2)
thanks!

回答(1 个)

KSSV
KSSV 2020-5-1
编辑:KSSV 2020-5-1
n = 10 ; % size of the array
a = zeros(n,1) ; % Initialize the array
a(1)=2 ; % value at n = 1
a(2)=3 ; % value at n = 2
% loop to get each value
for i = 3:n
a(i)=(1-a(i-1))/a(i-1) +a(i-2) ; % the formula you have given
end
  2 个评论
asaf omer
asaf omer 2020-5-1
thanks a lot , can u please teach how you did that?
KSSV
KSSV 2020-5-1
I have commented the steps......thanks is accepting the asnwer. :)

请先登录,再进行评论。

类别

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