Work 1: Add problem 1 matlab + report
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 78 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 103 KiB |
@@ -0,0 +1,47 @@
|
||||
% Parameters
|
||||
m = 0.75;
|
||||
L = 1.25;
|
||||
c = 0.15;
|
||||
g = 9.81;
|
||||
A0 = 4;
|
||||
omega = 2;
|
||||
|
||||
% Time span
|
||||
tspan = [0 20];
|
||||
dt = 1e-3;
|
||||
t_eval = 0:dt:20;
|
||||
|
||||
% ODE Function
|
||||
odefun = @(t, x) [
|
||||
x(2);
|
||||
(1/(m*L^2)) * (A0*sin(omega*t) - c*x(2) - m*g*L*x(1))
|
||||
];
|
||||
|
||||
x0 = [0; 0]; % Initial conditions
|
||||
[t, x] = ode45(odefun, t_eval, x0); % Solve
|
||||
|
||||
% Plots
|
||||
figure('Name', 'System responce', 'Position', [100, 100, 1280, 860]);
|
||||
subplot(2,1,1);
|
||||
plot(t, x(:,1)); ylabel('q(t) [rad]'); grid on; title('Γωνία');
|
||||
subplot(2,1,2);
|
||||
plot(t, x(:,2), 'r'); ylabel('dq(t) [rad/s]'); xlabel('t [sec]'); grid on; title('Γωνιακή Ταχύτητα');
|
||||
|
||||
saveas(gcf, 'Prob1_responce_20s.png');
|
||||
|
||||
|
||||
% Time span
|
||||
tspan = [0 90];
|
||||
t_eval = 0:dt:90;
|
||||
|
||||
x0 = [0; 0]; % Initial conditions
|
||||
[t, x] = ode45(odefun, t_eval, x0); % Solve
|
||||
|
||||
% Plots
|
||||
figure('Name', 'System responce', 'Position', [100, 100, 1280, 860]);
|
||||
subplot(2,1,1);
|
||||
plot(t, x(:,1)); ylabel('q(t) [rad]'); grid on; title('Γωνία');
|
||||
subplot(2,1,2);
|
||||
plot(t, x(:,2), 'r'); ylabel('dq(t) [rad/s]'); xlabel('t [sec]'); grid on; title('Γωνιακή Ταχύτητα');
|
||||
|
||||
saveas(gcf, 'Prob1_responce_90s.png');
|
||||
Reference in New Issue
Block a user