资源描述:
《matlab实现简单物理实验模拟.doc》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库。
1、一.ball.mclearvx=input('pleaseinputthespeedrationofVxandVi:');k=input('coefficientofrebound(<1):');ifk>=1return,endtm=(1+k)/(1-k);xm=vx*tm;figureplot([0,xm],[0,0],'LineWidth',3)gridonaxisequalaxis([0,xm,0,1])title('Trajectoeyofball','FontSize',16)xlabel(
2、'horizontaldistance(m)','FontSize',16)ylabel('Verticalheight(m)','FontSize',16)dt=0.001;tm=1;t=0:dt:tm;x=2*vx*t;y=1-t.^2;i=0;holdonwhiletm>0.01comet(x,y)plot(x,y,'LineWidth',2)i=i+1;tm=2*k.^i;t=0:0.001:tm;x=x(end)+2*vx*t;y=2*k^i*t-t.^2;end二.collision.mc
3、learm=0:0.5:2;n=length(m);theta=0:5:90;th=theta*pi/180;[M,TH]=meshgrid(m,th);PHI=2*asin(sin(TH/2)./(1+M))*180/pi;figure(1)plot(theta,PHI(:,1),'o-',theta,PHI(:,2),'s-',theta,PHI(:,3),'d-',...theta,PHI(:,4),'p-',theta,PHI(:,5),'h-')xlabel('itthetarm/c
4、irc','FontSize',16)ylabel('itphirm/circ','FontSize',16)title('Angleofballandobject','FontSize',16)gridonlegend([repmat('RatioofmassitM/mrm=',n,1),num2str(m')],2)DE=M./(1+M).*(1-cos(TH));figure(2)plot(theta,DE(:,1),'o-',theta,DE(:,2),'d-',theta,DE(
5、:,3),'s-',...theta,DE(:,4),'p-',theta,DE(:,5),'h-')xlabel('itthetarm/circ','FontSize',16)ylabel('DeltaitE/mgl','FontSize',16)title('MechanicalEnergy','FontSize',16)gridonlegend([repmat('RationofmassitM/mrm=',n,1),num2str(m')],2)三.niudunhuan.mcle
6、arrm=5;r=-rm:0.01:rm;[X,Y]=meshgrid(r);R=sqrt(X.^2+Y.^2);I=cos(pi*(R.^2+1/2)).^2;I(R>rm)=0;c=linspace(0,1,64)';figured=image(I*64);%ColorMap([c,c*0,c*0])%ColorMap([c,c,c*0])ColorMap([c,c,c])axisoffequaltitle('Newtonring','FontSize',16)pauseh=0;while1h=h
7、+0.02;I=cos(pi*(R.^2+1/2+2*h)).^2;I(R>rm)=0;set(d,'CData',64*I)drawnowifget(gcf,'CurrentCharacter')==char(27)break,endend一.stick.mclearg=10;v0=12;theta=input('angleofincidence:');th=theta*pi/180;w=10*pi;l=1;m1=0.2;m2=0.3;r1=l*m2/(m1+m2);r2=l*m1/(m1+m2);
8、t0=2*v0*sin(th)/g;n=200;t=linspace(0,t0,n);xc=v0*cos(th)*t;yc=v0*sin(th)*t-g*t.*t/2;x1=xc+r1*cos(w*t);y1=yc+r1*sin(w*t);x2=xc-r2*cos(w*t);y2=yc-r2*sin(w*t);figureh12=plot([x1(1);x2(1)],[y1(1);y2(1)],'-o','LineWidth',6);gridonaxis