Solving Matrix Equation in Simulink

Hi everyone, I have the following matrix euation:
Pdot=beta*P-P*(Phi*Phi'-error*H)*P
which P is a matrix with 4*4 size. I want to solve this equation in simulink.I use matlab embeded block.In every step,this equation should be solved and P is updated. what code i should write?

回答 (1 件)

Mischa Kim
Mischa Kim 2014 年 1 月 13 日

1 投票

The basic structure looks like this:
In the embedded function you compute Pdot which is inputted into an integrator that computes P. Don't forget to set initial conditions for P by opening the integrator. Assuming that all the other variables are constants the embedded function might look something like:
function Pdot = fcn(P)
beta = ...
Phi = ...
Phip = ...
error = ...
H = ...
Pdot = beta*P - P*(Phi*Phip - error*H)*P;

6 件のコメント

Sarah Miller
Sarah Miller 2014 年 2 月 1 日
Thanks Mischa,
I tried it,but it is sensitive to initial condition,and this error was ocurred:
Derivative input 1 of 'onlineident2/Integrator' at time 48.42 is Inf or NaN. Stopping simulation. There may be a singularity in the solution. Would you pls what can i do?
Mischa Kim
Mischa Kim 2014 年 2 月 1 日
Hard to say. Can you attach the model (see paper clip)?
What happens when you change integrator settings (in > Simulation > Model Configuration Parameters)? Decrease RelTol and AbsTol to say 1e-10 .
Sarah Miller
Sarah Miller 2014 年 2 月 2 日
I cant attach the model,Where is the paper clip?
Mischa Kim
Mischa Kim 2014 年 2 月 2 日
When you have a comment text box open, the paper clip is right on top of the window on the right, next to the Help button.
Sarah Miller
Sarah Miller 2014 年 2 月 2 日
Yeah,you are right.onlineident2.mdl was attached. In fact,I want to solve 2 following matrix equation:
Pdot=beta*P-P*(Phi*Phi'-error*dP)*P
tetaDot= P*error*Phi
The size of teta is 4*1 and size of P is 4*4. If Initial Condition of teta is chosen like the following:
[0.2-1.625 0.01-0.625 0.5 40]'
no error was happened,but actually teta equation wasnt solved.
it is sensitive to initial condition,and this error was ocurred:
Derivative input 1 of 'onlineident2/Integrator' at time 48.42 is Inf or NaN. Stopping simulation. There may be a singularity in the solution. Would you pls what can i do?
Would you pls tell me, how can i cope with it?
Sarah Miller
Sarah Miller 2014 年 2 月 2 日
Sorry,here you are

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

カテゴリ

ヘルプ センター および File ExchangeGeneral Applications についてさらに検索

タグ

質問済み:

2014 年 1 月 13 日

コメント済み:

2014 年 2 月 2 日

Community Treasure Hunt

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

Start Hunting!

Translated by