i have some error in my MATLAB code .
Afficher commentaires plus anciens
% EQUATION OF FLIGHT DYNAMICS IN STATE SPACE FORM
% state space matrix
A = [-0.00871, -0.019, -135, -32.12;
-0.0117, -0.311, 1931, -2.246;
0.0004761, -0.00673, -0.182, 0;
0, 0, 1, 0];
B = [6.24; -89.2; -9.80; 0];
C = [-0.127, 0.0698, -0.998, 0.01659;
-2.36, -1.02, 0.0103, 0;
11.1, -0.00735, -0.196, 0;
0, 1, 0, 0];
D = [-0.00498, 0.0426;
28.7, 5.38;
0.993, -6.90;
0, 0];
% control inputs (ELEVATOR,AILERON,RUDDER)
delta_e = @(t) [0; 0; 0; 0];
% state derivative function
state_derivative = @(t, x) A * x + B * delta_e(t);
% initial condition
initial_state = zeros(4,1);
%timespan--------------------------------------------------------------
tspan = [0, 10];
%solving equation using ode45
[t, x] = ode45(state_derivative, tspan, initial_state);
%%%ploting results------------------------------------------------------
figure;
subplot(2, 2, 1);
plot(t, x(:, 1));
xlabel('Time (s)');
ylabel('u');
title('velocity u');
subplot(2, 2, 2);
plot(t, x(:, 2));
xlabel('Time (s)');
ylabel('\omega');
title('angular velocity \omega');
subplot(2, 2, 3);
plot(t, x(:, 3));
xlabel('Time (s)');
ylabel('q');
title('pitch rate q');
subplot(2, 2, 4);
plot(t, x(:, 4));
xlabel('Time (s)');
ylabel('\theta');
title('pitch angle \theta');
Réponses (1)
Torsten
le 2 Oct 2023
B*delta_e(t)
is undefined since B and delta_e(t) are both 4x1.
Maybe you mean
B.*delta_e(t)
instead.
Catégories
En savoir plus sur Mathematics dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!