lab5solutions

lab5solutions - all v(1)=1; t(1)=0; h=0.0001; N=500; for...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
1 ECE220 LAB5 Solutions Created by Rong Guo %Set up the step size h to 0.001, the simulation time now is t=h*N=0.5s clear all v(1)=1; t(1)=0; h=0.001; N=500; for k=1:N t(k+1)=t(k)+h; v(k+1)=v(k)-h*t(k)^3*v(k)+h*10*t(k); end plot(t,v); grid on xlabel( 't' ) ylabel( 'v(t)' ) 0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.45 0.5 1 1.5 2 2.5 t v(t)
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 %Increase the step size h to 0.012, the simulation time now is t=h*N=6s clear all v(1)=1; t(1)=0; h=0.012; N=500; for k=1:N t(k+1)=t(k)+h; v(k+1)=v(k)-h*t(k)^3*v(k)+h*10*t(k); end plot(t,v); grid on xlabel( 't' ) ylabel( 'v(t)' ) %The simulation time now is long enough to plot a complete plot. It also can be seen that h=0.012 is suitable to plot an accurate plot. When t increases further, v(t) gradually decreases to zero. 0 1 2 3 4 5 6 0 1 2 3 4 5 6 t v(t)
Background image of page 2
3 %Decrease the step size h to 0.0001, the simulation time now is t=h*N=0.05s clear
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 4
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: all v(1)=1; t(1)=0; h=0.0001; N=500; for k=1:N t(k+1)=t(k)+h; v(k+1)=v(k)-h*t(k)^3*v(k)+h*10*t(k); end plot(t,v); grid on xlabel( 't' ) ylabel( 'v(t)' ) %The step is small enough for plotting an accurate plot, but simulation time now is not long enough for plotting the complete solution. 0.01 0.02 0.03 0.04 0.05 0.06 1 1.005 1.01 1.015 t v(t) 4 %Increase the step size h to 0.015, the simulation time now is t=h*N=7.5s clear all v(1)=1; t(1)=0; h=0.015; N=500; for k=1:N t(k+1)=t(k)+h; v(k+1)=v(k)-h*t(k)^3*v(k)+h*10*t(k); end plot(t,v); grid on xlabel( 't' ) ylabel( 'v(t)' ) %The simulation time is long enough for plotting the complete solution. However, the step is not small enough for plotting an accurate plot. 1 2 3 4 5 6 7 8-2-1 1 2 3 4 5 6 7 8 x 10 50 t v(t)...
View Full Document

This note was uploaded on 03/30/2009 for the course ECE 220 taught by Professor Nilson during the Spring '08 term at N.C. State.

Page1 / 4

lab5solutions - all v(1)=1; t(1)=0; h=0.0001; N=500; for...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online