How to solve singular matrix?
Show older comments
function dx = plant(t,x,u)
dx = zeros(6,1);
x1 = [x(1);x(2);x(3)];
x2 = [x(4);x(5);x(6)];
beta3=0.33;
beta4=2;
D=0.1;
M=1;
a1=0.1;%k1
a2=0.1;%k2
a3=0.01;%k3
a4=0.1;%k4
b=2.3;
f2= [(-(D*a1+a3)*x1(1)/M)-(D*a2*b^3*x2(3)/M);1;2];
G=[(1+a4*b^3)/M 0 0;0 1 0;0 0 1];
p1=[beta3*sin(x1(1));1;2];
p2=[beta4*(x2(1)^2);0;3];
dx1 = x2 + p1;
dx2 = f2 + G*u + p2;
dx = [dx1; dx2];

Accepted Answer
More Answers (1)
Hi @YING CHIH
Hear is another stabilizing input vector signal.
uExtIn = []; % No external Input signal
tspan = [0 20];
x0 = [1; zeros(5,1)];
[t, x] = ode45(@(t, x) plant(t, x, uExtIn), tspan, x0);
subplot(211)
plot(t, x(:,1:3)), grid on, legend('x_1', 'x_2', 'x_3', 'location', 'ne')
title('Responses of X1 vector')
subplot(212)
plot(t, x(:,4:6)), grid on, legend('x_4', 'x_5', 'x_6', 'location', 'ne')
title('Responses of X2 vector')
function dx = plant(t, x, u)
dx = zeros(6,1);
x1 = [x(1);
x(2);
x(3)];
x2 = [x(4);
x(5);
x(6)];
beta3 = 0.33;
beta4 = 2;
D = 0.1;
M = 1;
a1 = 0.1; % k1
a2 = 0.1; % k2
a3 = 0.01; % k3
a4 = 0.1; % k4
b = 2.3;
f2 = [(- (D*a1 + a3)*x1(1)/M) - (D*a2*b^3*x2(3)/M);
1;
2];
G = [(1+a4*b^3)/M 0 0;
0 1 0;
0 0 1];
p1 = [beta3*sin(x1(1));
1;
2];
p2 = [beta4*(x2(1)^2);
0;
3];
% ----------------------------------
k1 = 1;
k2 = 1;
x2d = - k1*x1 - p1;
dx2d = - k2*(x2 - x2d);
u = G\(dx2d - p2 - f2);
% ----------------------------------
dx1 = x2 + p1;
dx2 = f2 + G*u + p2;
dx = [dx1;
dx2];
end
Categories
Find more on Tuning Goals 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!

