Linearization of Non Linear with the editor
5 views (last 30 days)
Show older comments
How can i linearizate my non linear mimo system? This is my code
clc;
clear;
close all;
syms x1 x2 x3 u u1 u2 u3 x_punkt x1_punkt x2_punkt x3_punkt;
%% Modellparameter
a1 = 0.00751;
a2 = 0.00418;
a3 = 0.05;
a4 = 0.03755;
a5 = 0.02091;
a6 = 0.00315;
b1 = 0.00192;
b2 = 0.05;
b3 = 0.00959;
b4 = 0.1866;
b5 = 0.14;
k1 = 0.01061;
k2 = 2.5;
k3 = 6.84;
k4 = 2.5531;
%% nicht lineares System
x1_punkt = a1*x3 + a2*x2 - b1*u2 -b2*u2 - k1;
x2_punkt = -a3*x2*u2 + k2;
x3_punkt = -a4*x3 - a5*x2 +b3*u1 + ((a6*x3+b4)/(b5*u3+k3))*u3 + k4;
y1 = x1;
y2 = x2;
y3 = x3;
%% Ruhelage
xR = [1; 15; 70];
uR = [214.13; 3.33; 65.40];
%% Linearisierung
x = [x1 x2 x3];
y = [y1 y2 y3];
n = 3;
m = 3;
p = 3;
x_punkt = [x1_punkt x2_punkt x3_punkt]';
linear_A = jacobian(x_punkt, x);
linear_B = jacobian(x_punkt, u);
linear_C = jacobian(y, x);
A= subs(linear_A,x',xR');
A= subs(A,u',uR');
A = double(A)
B= subs(linear_B,x',xR');
B= subs(B,u',uR');
B = double(B)
C= subs(linear_C,x',xR');
C= subs(C,u',uAP');
C = double(C)
D = zeros(p,m);
sys = ss(A,B,C,D);
0 Comments
Answers (1)
Paul
on 10 Sep 2022
Edited: Paul
on 10 Sep 2022
Hi Hamza,
The code will run after fixing a few things, mostily mismatched dimensions. All I did was get it to run; did not check the underlying math and implementation.
Might not matter in this problem, but best to declare variables as real if they are, which I assume they are from the context of this problem.
syms x1 x2 x3 u u1 u2 u3 real
%% Modellparameter
a1 = 0.00751;
a2 = 0.00418;
a3 = 0.05;
a4 = 0.03755;
a5 = 0.02091;
a6 = 0.00315;
b1 = 0.00192;
b2 = 0.05;
b3 = 0.00959;
b4 = 0.1866;
b5 = 0.14;
k1 = 0.01061;
k2 = 2.5;
k3 = 6.84;
k4 = 2.5531;
%% nicht lineares System
x1_punkt = a1*x3 + a2*x2 - b1*u2 -b2*u2 - k1;
x2_punkt = -a3*x2*u2 + k2;
x3_punkt = -a4*x3 - a5*x2 +b3*u1 + ((a6*x3+b4)/(b5*u3+k3))*u3 + k4;
y1 = x1;
y2 = x2;
y3 = x3;
%% Ruhelage
xR = [1; 15; 70];
uR = [214.13; 3.33; 65.40];
%% Linearisierung
x = [x1 x2 x3];
y = [y1 y2 y3];
Define the input vector
u = [u1 u2 u3];
n = 3;
m = 3;
p = 3;
x_punkt = [x1_punkt x2_punkt x3_punkt]';
linear_A = jacobian(x_punkt, x);
linear_B = jacobian(x_punkt, u);
linear_C = jacobian(y, x);
Here, x is a row vector and xR is a column vector. So don't tanspose xR in the subs commands. Same thing with uR.
A= subs(linear_A,x',xR);
A= subs(A,u',uR);
A = double(A)
B= subs(linear_B,x',xR);
B= subs(B,u',uR);
B = double(B)
C= subs(linear_C,x',xR);
uAP is not defined, so I used uR instead, consistent with the with subs above.
% C= subs(C,u',uAP');
C= subs(C,u',uR);
C = double(C)
D = zeros(p,m);
sys = ss(A,B,C,D)
See Also
Categories
Find more on Systems Of Linear 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!