Why my graphic always on straight line?
2 views (last 30 days)
Show older comments
clc
clear
%% Nilai Data
Ip = 0.004026
Mp = 0.419
L = 0.108
Ir = 0.000189
Mr = 0.204
Im = 0.00548
Mm = 0.112
g = 10
%Equation
A1 = ((Mp+Mr+Mm)*g*L)/((Im+Ir+Ip)-Ir+(Mp+Mr+Mm)+L^2);
B1 = 1/((Im+Ir+Ip)-Ir+(Mp+Mr+Mm)+L^2);
B2 = ((1/Ir)+1/((Im+Ir+Ip)-Ir+(Mp+Mr+Mm)+L^2));
%Matriks
A = [0 0 1 0; 0 0 0 1; 0 A1 0 0; 0 A1 0 0];
B = [0;0;B1;B2];
C = [1 0 0 0; 0 1 0 0; 0 0 1 0; 0 0 0 1];
D = [0];
%% controllability
sys = ss(A,B,C,D);
Co = ctrb(sys)
Con = rank(Co)
%% stability
%tambahan
eig(A)
%% Polynomial Characteristic ITAE Method
Wn = 1.5
ITAE = [1 (2.1*Wn) (3.4*Wn^2) (2.7*Wn^3) (Wn^4)]
Roots1 = roots(ITAE)
K = place(A,B,Roots1)
Acl = A-B*K
E2 = eig(Acl)
Pcl = place(A,B,E2)
%% Call Simulink
[Out] = sim('simulasi.slx')
figure(1)
plot(Out.tout, Out.XITAE1);
title('Grafik response');
xlabel('Time');
ylabel('radian');
grid on;
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1563289/image.jpeg)
2 Comments
Sulaymon Eshkabilov
on 8 Dec 2023
Moved: Dyuman Joshi
on 8 Dec 2023
Post your simulink model simulasi.slx. Nobody can guess what you have in your Simulink model.
Answers (1)
Sam Chak
on 8 Dec 2023
Although you haven't provided the Simulink file 'simulasi.slx', I believe your result indicates that the system is in equilibrium (0, 0, 0, 0). What happened is that you simulated the model in Simulink with zero initial conditions and injected zero input. Naturally, the states will remain at the equilibrium value throughout the simulation unless you either inject a non-zero external input or use non-zero initial conditions. Three cases are demonstrated below, and yours most likely belongs to Case 2.
%% Nilai Data
Ip = 0.004026;
Mp = 0.419;
L = 0.108;
Ir = 0.000189;
Mr = 0.204;
Im = 0.00548;
Mm = 0.112;
g = 10;
% Equation
A1 = ((Mp+Mr+Mm)*g*L)/((Im+Ir+Ip)-Ir+(Mp+Mr+Mm)+L^2);
B1 = 1/((Im+Ir+Ip)-Ir+(Mp+Mr+Mm)+L^2);
B2 = ((1/Ir)+1/((Im+Ir+Ip)-Ir+(Mp+Mr+Mm)+L^2));
% Matriks
A = [0 0 1 0;
0 0 0 1;
0 A1 0 0;
0 A1 0 0];
B = [ 0;
0;
B1;
B2];
C = [1 0 0 0;
0 1 0 0;
0 0 1 0;
0 0 0 1]; % Sam: this is identity matrix, eye(4)
D = [0];
%% controllability
sys = ss(A, B, C, D);
Co = ctrb(sys);
Con = rank(Co);
%% stability
%tambahan
eig(A)
%% Polynomial Characteristic ITAE Method
Wn = 1.5;
ITAE = [1 (2.1*Wn) (3.4*Wn^2) (2.7*Wn^3) (Wn^4)]; % Sam: most likely from Dorf & Bishop
Roots1 = roots(ITAE);
K = place(A,B,Roots1)
Acl = A-B*K;
E2 = eig(Acl);
Pcl = place(A,B,E2);
%% Compensated system via pole-placement method
csys = ss(A-B*K, B, C, D);
N = 1/dcgain(csys);
csys = ss(A-B*K, B*N(1), C, D)
%% Case 1: Time response when input u is Unit-Step & initial condition is zero
step(csys), grid on, title('Case 1: Time Response with step input & zero x0')
%% Case 2: Time response when both input u & initial condition are zero
t = linspace(0, 12, 1201);
u = zeros(1, numel(t));
lsim(csys, u, t), grid on, title('Case 2: Time Response with zero input & zero x0')
%% Case 3: Time response when input u is zero & initial condition is non-zero
t = linspace(0, 12, 1201);
u = zeros(1, numel(t));
x0 = [1 0 0 0]; % initial condition
lsim(csys, u, t, x0), grid on, title('Case 3: Time Response with zero input & non-zero x0')
%% Call Simulink
% [Out] = sim('simulasi.slx')
% figure(1)
% plot(Out.tout, Out.XITAE1);
% title('Grafik response');
% xlabel('Time');
% ylabel('radian');
% grid on;
0 Comments
See Also
Categories
Find more on Dynamic System Models 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!