Linearization of Non Linear with the editor

5 次查看(过去 30 天)
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);

回答(1 个)

Paul
Paul 2022-9-10
编辑:Paul 2022-9-10
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)
A = 3×3
0 0.0042 0.0075 0 -0.1665 0 0 -0.0209 -0.0247
B= subs(linear_B,x',xR);
B= subs(B,u',uR);
B = double(B)
B = 3×3
0 -0.0519 0 0 -0.7500 0 0.0096 0 0.0109
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)
C = 3×3
1 0 0 0 1 0 0 0 1
D = zeros(p,m);
sys = ss(A,B,C,D)
sys = A = x1 x2 x3 x1 0 0.00418 0.00751 x2 0 -0.1665 0 x3 0 -0.02091 -0.02467 B = u1 u2 u3 x1 0 -0.05192 0 x2 0 -0.75 0 x3 0.00959 0 0.01088 C = x1 x2 x3 y1 1 0 0 y2 0 1 0 y3 0 0 1 D = u1 u2 u3 y1 0 0 0 y2 0 0 0 y3 0 0 0 Continuous-time state-space model.

类别

Help CenterFile Exchange 中查找有关 Systems Of Linear Equations 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by