Linearizing Symulink dynamic model to retrieve coefficient matrices A B C D (without using linmod function) with Least Squares method

Hello,
I wonder how to implement linearazing the dynamic model from simulink to the linear one. I know that there are built-in functions, however, I have to implement this from scratch using Least Squares method.
The model consists of two fluid tanks with free drainage. The maximum height of tank is 15m, which I have already done in Simulink.
Subsystem
I have to use h1, h2, h1_p (derivate of h1), h2_p (derivate of h2), and "u", which is my Qwe (input signal 5.373)
Could you help me to implement the "Least Squares" method to retrieve A, B, C, D matrices that are part of the linear model?
My start program:

3 commentaires

Hi Adrian,
Could you list out the differential equations for the two fluid tanks with parameters?
Are you allowed to use the linearize function?
Hi Sam,
here are the differential equations:
Everything works perfectly in Simulink. Initial condition in both tanks integrators is 0.
The main purpose is to retrieve linear matrices (A, B, C, D) without using any built-in functions that return them immediately in one line (like linmod etc.). It has to be calculated in matlab file using Least Square method and h1, h2, h1_derivative, h2_derivate and input signal (Qwe).
Thank you for help!
Thanks for the ODEs. I know that least squares method is commonly used in curve-fitting problems, dealing with sparse matrices, and data-driven system identification. But the linearization method that I know of usually involves finding the Jacobian.
Perhaps you can first create the symbolic differential equations. Follow the examples here.
syms h1(t) h2(t) Q S1 S2 Sw1 Sw2 phi1 phi2 g
ode1 = diff(h1) == Q/S1 - (Sw1*phi1*sqrt(2*g*(h1 - h2)))/S1;
ode2 = diff(h2) == (Sw1*phi1*sqrt(2*g*(h1 - h2)))/S2 - (Sw2*phi2*sqrt(2*g*h2))/S2;
odes = [ode1; ode2]
Let's hope other users who are good at math/physics/MATLAB can help out.

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Numerical Integration and Differential Equations dans Centre d'aide et File Exchange

Commenté :

le 30 Mai 2022

Community Treasure Hunt

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

Start Hunting!

Translated by