How to code recursive function of a function with dependent variable inside?? sorry, I dont know how to explain.
이전 댓글 표시
My program is very difficult, I do not know how to write please help.
The goal of my program is to find vector of variable u which can be compute by using 3 equation, 2 are recursive.
let i be index in a vector array, and function f depend on vector x and u.
1. state x_i+1 = x_i +f( x_i , u_i ) , with x_0 is given
2. cosatate lambda_i = lambda_i+1 + H( x_i , lambda_i+1 , u_i), with last value of lambda is given and H is a function depend on previous lambda, x and u.
It can be seen that fist I have to find state subsequent x by forward recursive and then lambda by backward recursive. After that I must sub these two arrays in to the final function.
3. function F( x,lambda,u )
From third equation, the only variable left is u. Then, I will use some method like fsolve to find the value of u later.
Please help, because I cannot write function F by myself because it compose by very complicated equation as I explain above.
답변 (1개)
Panagiotis Panos Katranitsas
2012년 2월 25일
Hi Tang, generally when you have to calculate recursive equations you need to initialise that parameters and then use them inside a loop.
Please have a look at the following code, I calculate the Qt based on Qt-1. The A,B,u,Proc_noise are constants. This code is for kalman filter.
Q= [0]; %initized state
for t = 0 : sampling: duration
Q= A * Q+ B * u + Proc_noise; <== Check that line
end
카테고리
도움말 센터 및 File Exchange에서 Simulink Functions에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!