夏天521 发表于 2009-10-21 16:19

请教怎么画三者的关系曲线

我的程序在下面列出了,其中我想画a(n),e(n),p(n)三者的关系曲线,他们在程序中的关系是这样的a(n+3)=a(n+2)+ca(n+2);e(n+3)=e(n+2)+ce(n+2);p(n+3)=exp(-0.5*(a(n+3).^2+e(n+3).^2));我还想问一下这样的图如何和曲线a=-5:5,e=-5;5;p=exp(-0.5*(a.^2+e.^2));画在一张图中,再次谢谢各位了
程序:
a=; e=; p(1)=exp(-0.5*(a(1).^2+e(1).^2));
p(2)=exp(-0.5*(a(2).^2+e(2).^2)); p(3)=exp(-0.5*(a(3).^2+e(3).^2));
cp(1)=p(2)-p(1); cp(2)=p(3)-p(2); ca(1)=a(2)-a(1); ca(2)=a(3)-a(2);
ce(1)=e(2)-e(1); ce(2)=e(3)-e(2); w=1; c(1)=5.5300e-005; d(1)= 0.0477; n=1;
t1=c(n); t2=d(n); t3=p(n);
whilet3<0.98%循环控制条件
   c(n)=(-cp(n)*ce(n+1)+ce(n)*cp(n+1))/(ca(n+1)*ce(n)-ca(n)*ce(n+1));
   d(n)=-(cp(n+1)*ca(n)-ca(n+1)*cp(n))/(ca(n+1)*ce(n)-ca(n)*ce(n+1));
   cr=sqrt(ca(n).^2+ce(n).^2);
   q=sqrt(c(n).^2+d(n).^2);%q为cos中分母的公共部分
   cosm=c(n)/q; cosn=d(n)/q;
   ca(n+2)=cr*cosm; ce(n+2)=cr*cosn;
   a(n+3)=a(n+2)+ca(n+2); e(n+3)=e(n+2)+ce(n+2);
   p(n+3)=exp(-0.5*(a(n+3).^2+e(n+3).^2));
   g1=p(n+3);
   cp(n+2)=p(n+3)-p(n+2);
   if n>100,break,end
   t3=p(n+3); n=n+1;
end
disp(n),disp(p)

[ 本帖最后由 ChaChing 于 2009-10-24 10:47 编辑 ]

friendchj 发表于 2009-10-22 02:30

help plot3 and hold on

夏天521 发表于 2009-10-22 09:32

不是阿.我画的是曲面,但是两个图的变量是不同的,这样能画在一张图上吗,谢谢了

请教各位了,我画了一个三维曲面程序下面给出,是a,e,p三者的关系,同是我根据我的程序又得到了a(n)e(n)p(n)三者的关系,我该如何将这两个图形画在一个三维坐标系内呢?请各位指点一下.再次感谢了
三维曲面程序:
= meshgrid(-5:0.2:5,-5:0.2:5); p = exp(-0.5*(a.^2+e.^2));
mesh(a,e,p); xlabel('\bfa'); ylabel('\bfe'); zlabel('\bfp');
我的程序:
a=; e=;
p(1)=exp(-0.5*(a(1).^2+e(1).^2)); p(2)=exp(-0.5*(a(2).^2+e(2).^2)); p(3)=exp(-0.5*(a(3).^2+e(3).^2));
cp(1)=p(2)-p(1); cp(2)=p(3)-p(2); ca(1)=a(2)-a(1); ca(2)=a(3)-a(2);
ce(1)=e(2)-e(1); ce(2)=e(3)-e(2); w=1; c(1)=5.5300e-005; d(1)= 0.0477;
n=1; t1=c(n); t2=d(n); t3=p(n);
whilet3<0.98%sqrt(t1.^2+t2.^2)>=0.00000001循环控制条件
   
c(n)=(-cp(n)*ce(n+1)+ce(n)*cp(n+1))/(ca(n+1)*ce(n)-ca(n)*ce(n+1));
d(n)=-(cp(n+1)*ca(n)-ca(n+1)*cp(n))/(ca(n+1)*ce(n)-ca(n)*ce(n+1));

cr=sqrt(ca(n).^2+ce(n).^2); q=sqrt(c(n).^2+d(n).^2);%q为cos中分母的公共部分
cosm=c(n)/q; cosn=d(n)/q; ca(n+2)=cr*cosm; f1=ca(n+2);%
ce(n+2)=cr*cosn; f2=ce(n+2);%
a(n+3)=a(n+2)+ca(n+2); e(n+3)=e(n+2)+ce(n+2);
p(n+3)=exp(-0.5*(a(n+3).^2+e(n+3).^2)); g1=p(n+3);
cp(n+2)=p(n+3)-p(n+2);

if n>100,break,end
   t3=p(n+3);
n=n+1;

end
disp(n)
disp(p)

[ 本帖最后由 ChaChing 于 2010-4-26 21:34 编辑 ]

夏天521 发表于 2009-10-22 10:33

我已经画出来了,:lol

friendchj 发表于 2009-10-22 13:13

回复 板凳 夏天521 的帖子

利用hold on,例如:
clc
clear
=meshgrid(-1:.1:1);
mesh(x,y,x.^2+y*10)
hold on
peaks;
页: [1]
查看完整版本: 请教怎么画三者的关系曲线