Professional Documents
Culture Documents
Task 1
Example 1
B = 30;
Fa = 300;
dvdt = Fa/M-B/M*v;
end
v0 = 0;
[t,v] = ode45('cruise_speed', [0,125], v0);
plot (t,v); grid on;
title ('cruise speed time response to a constant fraction force')
Example 2
function dXdt=mass_spring(t, X)
%flow rate
M=750; %(Kg)
B=30; %( Nsec/m)
Fa=300; %N
K=15; %(N/m)
r=1;
dXdt(1,1)=X(2);
dXdt(2,1)=-B/M*X(2)-K/M*X(1)^r+Fa/M;
end
When r=3
Exercise 2
function dydt=mass_spring(t, y)
%flow rate
M=10; %(Kg)
B=0.5; %( Nsec/m)
Fa=1; %N
K=1; %(N/m)
dydt(1,1)=y(2);
dydt(2,1)=-B/M*y(2)-K/M*y(1)+Fa/M;
end
y0=[0,0];