How to reference past values?

1 次查看(过去 30 天)
Vert
Vert 2014-10-16
how do I reference past values of a function?
as in f(x) = 0.7*(f(x-1))

回答(1 个)

Roger Wohlwend
Roger Wohlwend 2014-10-16
编辑:Roger Wohlwend 2014-10-16
In general you have to use a loop for that. However, in your simple case it is not necessary.
f(x) = 0.7^x * f(0)
where f0 is the inition condition.
So if you want a vector with the first n values of the function, use the following Matlab code:
f = 0.7.^(1:n) * f0
where f0 is the initial condition, a scalar.

类别

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