International Islamic University, Islamabad
LAB EXPERIMENT
Date of Experiment:
Report submitted on:
Marks obtained:
Remarks: .
Instructors Signature:
SOLUTION:
STEP(1)
function dYdt=mass_spring(t, Y)
M=10; %(Kg)
B=.5; %( Nsec/m)
Fa=1; %N
K=1; %(N/m)
dYdt=[0;0];
dYdt(1)=Y(2);
dYdt(2)=-B/M*Y(2)-K/M*Y(1)+Fa/M;
STEP(2)
>> Y0=[0; 0]; %(initial speed and position)
>> [t,Y]=ode45('mass_spring', [0 100],Y0);
plot(t,Y)
IN SIMULINK
SOLUTION
STEP(1)
function dqdt=speed(t, q)
R=1000; %(Kohm)
C=2; %( uF)
Vin=5; %V
dqdt=Vin/R-(1/(C*R))*q;
STEP(2)
>> q0= 0; %(initial speed)
>> [t,q]=ode45('speed', [0 20000],q0);
>> >> plot(t,q);
SIMULINK
SOLUTION:
STEP(1)
function dqdt=mass_spring(t, q)
Vin=10; %(v)
R=15; %( Kohm)
L=1100; %nH
C=3.3; %(pF)
dqdt=[0;0];
dqdt(1)=q(2);
dqdt(2)=
(Vin/L)-(R/L)*q(2)-(1/(L*C)*q(1));
STEP(2)
>> q0=[0; 0];
>> [t,q]=ode45('mass_spring', [0 1000],q0);
>> plot(t,q);
SIMULINK