Sei sulla pagina 1di 2

clear all

close all

clc

%inilizzazione delle variabili

t = 0; %s

x = 0.0; %m

v = 2.0; %m/s

%Costanti

dt = 0.1; %s

Tmax = 10.0; %s

Fo = 3.0; %N

m = 10; %kg

f = 4; %s^(-1)

c = 4; %N/(m/s)

k = 80; %N/m

% Vettori di memorizzazione variabili

v_vett = v;

x_vett = x;

t_vett = t;

while t<=Tmax

F = Fo*cos(2*pi*f*t)-k*x-c*v;

a = F/m;

v = v+a*dt;

x = x+v*dt;

t = t+dt;

v_vett = [v_vett;v];

x_vett = [x_vett;x];

t_vett = [t_vett;t];

end
plot(t_vett, x_vett, t_vett, v_vett)

xlabel('tempo [s]');

ylabel('spostamento [m] , velocità [m/s]');

title('MASSA-MOLLA-SMORZATORE')

legend('X' , 'V')

grid on;

Potrebbero piacerti anche