フィルターのクリア

How can I solve these recursive equations ?

10 ビュー (過去 30 日間)
Fox
Fox 2016 年 1 月 13 日
コメント済み: Fox 2016 年 1 月 15 日
Hello I want to take the solution of a equation and use this as a new variable and so on like in the following demonstrated.
x1=a+bx0
x2=a+bx1
x3=a+bx2 ......
How can I solve this by a loop or so because I have to do this until 743 and I need every of the x values, so in the end I want to have a x matrix with 743x1 dimension.
  1 件のコメント
Stephen23
Stephen23 2016 年 1 月 14 日
編集済み: Stephen23 2016 年 1 月 14 日
Whatever you do, do not create the variable names dynamically, just save the values in a vector instead. Here is an explanation of why it is very poor programming practice to create variable names dynamically:

サインインしてコメントする。

採用された回答

Torsten
Torsten 2016 年 1 月 13 日
xn = a*(1-b^n)/(1-b) + b^n*x0.
Now insert n=743.
Best wishes
Torsten.
  6 件のコメント
Torsten
Torsten 2016 年 1 月 14 日
The formula is only valid for constant a. For a depending on n you will have to refer to the loop solution from above:
x(1) = some value;
for m=1:742
x(m+1)=a(m+1)+b*x(m);
end
Best wishes
Torsten.
Fox
Fox 2016 年 1 月 15 日
Thank you very much.

サインインしてコメントする。

その他の回答 (1 件)

Guillaume
Guillaume 2016 年 1 月 14 日
The filter function allows you to compute all your elements in one go for both use cases (a constant or variable):
  • constant a and b:
numelemrequired = 743;
x = filter(1, [1 -b], [x0 repmat(a, 1, numelemrequired)])
  • variable a and b:
x = filter(1, [1 -b], [x0 a]) %where a is a vector of length 743
Note that your a, b, and x are not the same a, b, and x used by the documentation of filter.
  1 件のコメント
Fox
Fox 2016 年 1 月 15 日
thanks it works

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeMathematics and Optimization についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by