Recursion is not a good idea on an iteration of this sort where at each step two different earlier levels are consulted. At the first step there must be two recursive calls. At the second step there must be two calls, each of which requires two calls. As you progress along the iteration, the number of calls expands exponentially. This is of course a great waste because there will be recursive calls made repeatedly for the same value of i.
It is much, much better to do the iteration with a for-loop or while-loop:
for i = 2:50
x(i) = x(i-1)*(1+0.1*e(t(i)))-0.01*x(i-2);
end
Note: you haven’t told us what e(t) is. Is this where the stochastic property comes in? If so, you would have the repeat the above loop a great many times to simulate this stochastic behavior accurately.
2 Comments
Direct link to this comment
https://de.mathworks.com/matlabcentral/answers/322753-how-can-i-write-such-an-equation-on-matlab#comment_425051
Direct link to this comment
https://de.mathworks.com/matlabcentral/answers/322753-how-can-i-write-such-an-equation-on-matlab#comment_425051
Direct link to this comment
https://de.mathworks.com/matlabcentral/answers/322753-how-can-i-write-such-an-equation-on-matlab#comment_425080
Direct link to this comment
https://de.mathworks.com/matlabcentral/answers/322753-how-can-i-write-such-an-equation-on-matlab#comment_425080
Sign in to comment.