Linearizing Symulink dynamic model to retrieve coefficient matrices A B C D (without using linmod function) with Least Squares method
Show older comments
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 Comments
Adrian Tworek
on 28 May 2022
Sam Chak
on 30 May 2022
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.
https://www.mathworks.com/help/symbolic/analyze-and-manipulate-differential-algebraic-equations.html
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.
Answers (0)
Categories
Find more on Numerical Integration and Differential Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!