Calculate an expression in MAtlab
1 回表示 (過去 30 日間)
古いコメントを表示
(Sorry i don't know a better title)
I have (n=0,1,2,3,....)
How can I calculate the below expression with matlab codes ?
Thank you
0 件のコメント
採用された回答
Star Strider
2019 年 5 月 8 日
It depends on what ‘T’ and ‘c’ are.
If they are scalars, this would likely work:
T = rand;
c = rand;
x(1) = rand;
N = 10;
for k = 1:N
x(k+1) = x(k)*T+c;
end
2 件のコメント
Star Strider
2019 年 5 月 8 日
‘Is there any way I can type x(0) instead of x(1) ?’
Not in MATLAB. In MATLAB, indices must be integers greater than 1.
However you can choose to display them the way you want:
for k = 1:numel(x)
fprintf('x(%d) = %.4f\n', k-1, x(k))
end
producing:
x(0) = 0.6905
x(1) = 1.0766
x(2) = 1.2961
...
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Loops and Conditional Statements についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!