ee150_protonbeam_1plot

ee150_protonbeam_1plot -...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
function ee150_protonbeam_1plot(v0, B, Ei, dE, Ef) dt=1e-9; duration=10e-6; q=1.6e-19;%C m=(1.67e-27);%Kg l=duration/dt; for E=Ei:dE:Ef vy=zeros(1,l+1); vx=zeros(1,l+1); x=zeros(1,l+1); y=zeros(1,l+1); vx(1,1)=v0; w=(B*q)/m; a=(E*q)/m; for t=1:l vx(1,t+1)=vx(1,t)+dt*(w*vy(1,t));
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: vy(1,t+1)=vy(1,t)+dt*(-w*vx(1,t)+a); x(1,t+1)=x(1,t)+vx(1,t)*dt; y(1,t+1)=y(1,t)+vy(1,t)*dt; end if y==0; figure; plot(x,y,'r');title(num2str(E));xlabel('X-Pos(m)');ylabel('Y-Pos(m)'); axis([-0.2 0.2 -0.1 0.1]); end end...
View Full Document

This note was uploaded on 09/15/2011 for the course EE 150 at USC.

Ask a homework question - tutors are online