HI all,
I've been trying to simulate the aircraft response to different control inputs using the state space method. The code first creates the matrices for the state space, then I let MATLAB create the state space model using the ss command. Then to look at the responses, I use the tf command to make transfer functions of the state space. These transfer functions are used to calculate the response to a a 1 degree step input. However, the command step does not give the correct results. So I tried using the lsim command, however, these results weren't correct either.
So my question is; how do i simulate a 1 degree step input on the state space in MATLAB?
P.S. I'm using college values for the state space and I have figures of how the output should look like.
— Used code: —
% State matrix (aerodynamic stability derivatives, u – w – q – theta)
A = [0.00501 0.00464 -72.9 -31.34;
-.08570 -.54500 309 -7.4;
0.00185 -0.00767 -0.395 0.00132;
0 0 1 0];
% Input matrix (control coefficients, aileron – rudder)
B = [5.63;
-23.8;
-4.51576;
0];
% Output matrix
C = [1 0 0 0;
0 1 0 0;
0 0 1 0;
0 0 0 1;
0 0.00316 0 0;
0 -0.00316 0 1];
% Direct matrix
D = 0;
% Creation of state space & transfer functions (u, w, q, theta)
state_space = ss(A,B,C,D);
transfer_function = tf(state_space);
% Input of elevator
input = [ones(1,10), zeros(1,991)]; % Step of 1 for 1 second (in combination with time vector)
t = 0:0.1:100; % Time vector
% Calculation of response to elevator
[u,Y1] = lsim(transfer_function(1,1),input,t); % Velocity, x-axis
[w,Y2] = lsim(transfer_function(2,1),input,t); % Velocity, z-axis
[q,Y3] = lsim(transfer_function(3,1),input,t); % Angular velocity, pitch rate
[theta,Y4] = lsim(transfer_function(4,1),input,t); % Pitch angle
[alfa,Y4] = lsim(transfer_function(5,1),input,t); % Pitch angle
[gamma,Y4] = lsim(transfer_function(6,1),input,t); % Pitch angle
subplot(6,1,1);
plot(t,u);
title('Linear velocity u [ft/s]');
subplot(6,1,2);
plot(t,w);
title('Linear velocity w [ft/s]');
subplot(6,1,3);
plot(t,q);
title('Angular velocity q [ft/s]');
subplot(6,1,4);
plot(t,theta);
title('Pitch angle Theta [rad]');
subplot(6,1,5);
plot(t,alfa);
title('Angle Alfa [rad]');
subplot(6,1,6);
plot(t,gamma);
title('Angle Gamma [rad]');
sgtitle('Boeing 747 response to 1 degree 1 second on elevator');
Best Answer