How to code recursive function of a function with dependent variable inside?? sorry, I dont know how to explain.

5 visualizzazioni (ultimi 30 giorni)
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.

Risposte (1)

Panagiotis Panos Katranitsas
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
  1 Commento
Tang
Tang il 26 Feb 2012
Sorry, for wasn't clear question. I mean I don't know how to manage the function.
Usually a function will return a value of scalar or vector or matrix, right? But, my function is likely return a function that depended on vector *u* .
It like function state x will return a function with unknown variable vector *u* inside and it cannot manage it in to the form of Au=b.
I try to use symbolic to generate my function state x and costate lambda, it took forever to generate the equation since, my unknown vector u has 30 element inside and will be more than this in more complicated system, so it must be a better way.
please help me

Accedi per commentare.

Categorie

Scopri di più su Simulink Functions in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by