有没有人可以帮我用matlab编一个程序,可以显示出动态物理图像的,最好是有关热学或者电磁学的!
老师只是让随便编一个,就是那种动态图像的。最好是那种输入某个数据,图像就根据数据不同动的不同。例如单摆...在图像界面输入某个角度,单摆就根据这个角度运动。只是现在让编热学或电磁学的。我对MATLAB一点都不懂。大家帮帮忙,什么数据都行。
clear,clc,close all;v=input(‘input the angel:’);%输入角度ti=v*pi/180;plot([-0.2;0.2],[0;0],'color','y','linestyle','-',... 'linewidth',10); %画初始位置的单摆 g=0.98; %重力加速度,可以调节摆的摆速 l=1; theta0=pi/4; x0=l*sin(theta0); y0=(-1)*l*cos(theta0); axis([-0.75,0.75,-1.25,0]); axis('off'); %不显示坐标轴 %创建摆锤 head=line(x0,y0,'color','r','linestyle','.',... 'erasemode','xor','markersize',40); %创建摆杆 body=line([0;x0],[0;y0],'color','b','linestyle','-',... 'erasemode','xor'); %摆的运动 t=0; dt=0.01; while 1 t=t+dt; theta=theta0*cos(sqrt(g/l)*t); x=l*sin(theta); y=(-1)*l*cos(theta); set(head,'xdata',x,'ydata',y); set(body,'xdata',[0;x],'ydata',[0;y]); drawnow; if t==ti %满足条件退出循环breakendend |
|