Sei sulla pagina 1di 3

Exercise # 1

Consider the mechanical system depicted in the figure.


The input is given by (), and the output is given by ().
Determine the transfer function from () to () and using
MATLAB, write a m-file and plot the system response to a unit
step input. Let = 10, = 1 and = 0.5. Show that the peak
amplitude of the output is about 1.8.

M-file
function dxdt=mech_sys(t,x)
k=1;
m=10;
b=.5;
f=1;
dxdt=[0;0];
dxdt(1)=x(2);
dxdt(2)=f/m-b/m*x(2)-k/m*x(1);
end
command window
>>x0=[0;0];
>> [tm,disp]=ode45('mech_sys',[0,200],x0);
>> plot(tm,disp);
>> xlabel('Time'); ylabel('Distance');

Exercise # 2:
Find the solution of 1st order differential
equation of RC circuit given below using Matlab
ode45 function. Let = 5, = 100 and =
2.

M-file
function dqdt=charge_onC(t,q)
R=100000;
C=2*10^(-6);
Vin=5;
dqdt=(Vin/R )- (q/(C*R));
end

command window
>> q0=0;
>> [tm,chrge]=ode45('charge_onC',[0 1.4],q0);
>> plot(tm,chrge)

>>xlabel('Time');ylabel('Charge on Capactor');

Exercise 3:
Find the unit step response of RLC circuit given below
using Matlab. Also solve 2nd order differential equation
using Matlab ode45 function.

M-file
function dqdt=chrge_tm(t,q)
Vi=10;
L=1100*10^(-9);
R=15000;
C=3.3*10^(-6);
dqdt=[0;0];
dqdt(1)=q(2);
dqdt(2)=(Vi/L) -((R/L)*q(2)) - (q(1)/(L*C));
end

Command window
>> q0=[0;0];
>>plot(tm,chrge)
>> [tm,chrge]=ode45('chrge_tm',[0,15],q0);

Potrebbero piacerti anche