Simple Recurrence in Matlab
19 ビュー (過去 30 日間)
古いコメントを表示
i have a question:
"Write a MATLAB program to compute wn for n = 1, 2, . . . , num where num is entered by the user, and display the values in two columns: n, wn (with appropriate headings)."
The recurrence for this question is W(0) = 25, Wn = W(n-1) +7 -(7*(n+1)/n) n ≥ 2
for the life of me i cant work out how to take this equation on matlab and take a "num" inputed by the user for the value of n
ie) n=1 W(1) = 25 + 7 - 14 = 18
n=2 W(2) = 18 + 7 - 10.5 = 14.5 and so on
0 件のコメント
採用された回答
KSSV
2017 年 3 月 30 日
N = 100 ;
W = zeros(N,1) ;
W(1) = 25 ;
for n = 2:N
W(n) = W(n-1) +7 -(7*(n+1)/n) ;
end
0 件のコメント
その他の回答 (2 件)
Avag Poghosyan
2019 年 1 月 9 日
N = 100 ;
W = zeros(N,1) ;
W(1) = 25 ;
for n = 2:N
W(n) = W(n-1) +7 -(7*(n+1)/n) ;
end
0 件のコメント
bhavuk seth
2020 年 5 月 7 日
N = 100 ;
W = zeros(N,1) ;
W(1) = 25 ;
for n = 2:N
W(n) = W(n-1) +7 -(7*(n+1)/n) ;
end
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Programming Utilities についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!