Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %-------------------------------------
- %Homework 4
- %Greenwood Problem 4.2
- %Henry Lam
- %-------------------------------------
- global A1 A2
- %Given value of circuit elements
- L=0.12; %Henry
- C=32e-6; %Farads
- R=92; %Ohm
- t0=0; %define the initial time
- tf=15e-3; %define the final time
- nsteps=500; %number of steps from t0 to tf)
- hsteps=(tf-t0)/nsteps;
- tspan=t0:hsteps:tf;
- A1=[0 -1/C;1/L 0]; %When only S1 is closed.
- A2=[-1/(R*C) -1/C;1/L 0]; %When S2 is closed while S1 is already closed.
- disp('Eigenvalue of A1 are:')
- lambda1=eig(A1);
- disp('Eigenvalue of A2 are:')
- lambda2=eig(A2);
- x0=[40e3 0.0]; % initial conditions
- [t,x]=ode23('hw4_gw42',tspan,x0);
- subplot(2,1,1)
- plot(t,x(:,1),'Linewidth',1.5), grid on
- title('When S1 is closed, S2 is open');
- xlabel('time(sec)')
- ylabel('Vc(Volts)')
- subplot(2,1,2)
- plot(t,x(:,2),'Linewidth',1.5), grid on
- title('When S1 and S2 are closed');
- xlabel('time(sec)')
- ylabel('iL(amps)')
- The switch S1 closed first then 5ms later switch S2 close
- function xdot=hw4_gw42(t,x)
- global A1 A2
- %state variables;
- %x(1)=Vc, x(2)=iL
- xdot=zeros(2,1);
- if(t<5e-3)
- xdot=A1*x; %state space equation when S1 is closed.
- else
- xdot=A2*x; %state space equation when S1 and S2 are closed.
- End
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement