t=0:0.01:6*pi
v0x=1
v0y=1
a1=1
y1=v0y*t+0.5*a1*t.*t
x1= v0x*t
a2=cos(t)
y2=v0y*t+0.5*a2.*t.*t
x2= v0x*t
subplot(2,2,3)
plot(x1,y1,'g',x2,y2,'r')
grid on
title('叠加')
legend('匀强电场带闹','周期变化电场',3)
x3=t
y3=cos(t)
z3=sin(t)
for i=1:length(t)
subplot(2,2,1)
plot(x1(1:i),y1(1:i))
axis([0,8,0,30])
grid on
hold on
subplot(2,2,1)
plot(x1(i),y1(i),'r.','markersize',20)
title('匀强电场')
grid on
hold off
subplot(2,2,2)
plot(x2(1:i),y2(1:i))
axis([0,8,-30,30])
title('周期变埋行备化电场')
grid on
hold on
subplot(2,2,2)
plot(x2(i),y2(i),'r.','markersize',20)
grid on
hold off
subplot(2,2,4)
plot3(x3(1:i),y3(1:i),z3(1:i))
hold on
grid on
axis([0,10,-1,1,-1,1])
title('匀强电场和弯毁磁场')
subplot(2,2,4)
plot3(x3(i),y3(i),z3(i),'r.','markersize',20)
view(-100,500)
hold off
M(i)=getframe
end
movie(M,1)
%我想用matlab对函段举数dy/dx=(x-y)/(1-y-x)进行模拟,请问该怎样做,%解微分方程!!
%归一化:
%令y=y(1)
%x=t=y(2)
%dy(1)/dt=(y(2)-y(1))/(1-y(1)-y(2))
%dy(2)/dt=1
%函数文件
founction dy=fun1(t,y)
dy=zeros(2,1)
dy=[(y(2)-y(1))/(1-y(1)-y(2))1]
%以上保存为fun1.m文件
%以下是脚本程序
clear
ts=0:0.01:?%时间范戚燃逗围
y0=[??]%函数边界条件y(0),x(0)
[t,y]=ode45('高卖fun1',ts,y0)
plot(y(:,1),y(:,2))
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)