fanzhenjie 发表于 2008-8-22 22:14

请教:如何控制坐标按相同的比例显示axis equal写进去后图形就显示不全了!急

我要画一个三维图,且保证图形不失真,也保持坐标比例一致!我加了axis equal后为什么图形就显示不全了呢?就说了,我不加那句命令图形还显示的挺完整,但就是示意图,由于本身X范围小,而Z,Y的范围都比较大,但我需要的是真实的比例那种图,就是不要失真!我加了那句指令后,就变得Z轴下方就显示的不全,而且Z轴的正负半轴也显示不全了!不知道为什么,希望各位指点一下呀!谢谢!

[ 本帖最后由 fanzhenjie 于 2008-8-23 09:06 编辑 ]

sigma665 发表于 2008-8-23 16:58

调整下坐标的显示范围

fanzhenjie 发表于 2008-8-23 21:36

回复 沙发 sigma665 的帖子

怎么调整坐标的显示范围呀,我都尽量把坐标范围调的比较大呢!谢谢,希望详细告诉我一下!

fanzhenjie 发表于 2008-8-23 21:40

我加了AXIS EQUAL后为什么图形就显示不全了呢,要求比例一致

c1=input('请输入大半径532/c1时的较小的c1值,赋值到c1:'); if (c1<1)|(c1>6),break;end
c2=input('请输入小半径532/c2时的较大的c2值,赋值到c2:'); if (c2<1)|(c2>6),break;end
m=input('请输入最下面圆弧口径,范围是25到35,赋值到m:'); if (m<25)|(m>35),break;end
n=input('请输入过渡区域口径,范围是10到16,赋值到n:'); if (n<10)|(n>16),break;end
a=523./c1; b=523./c2; d=b-sqrt(b.^2-(-m).^2);
=meshgrid(0:0.1:d,-m:0.1:m); z1=sqrt((m-sqrt(2.*b.*x1-x1.^2)).^2-y1.^2);
mesh(x1,y1,z1); hold on;
=meshgrid(0:0.1:d,-m:0.1:m); z2=-sqrt((m-sqrt(2.*b.*x1-x1.^2)).^2-y1.^2);
mesh(x2,y2,z2); hold on;
e=(b.*(n.^2)-sqrt((b.^2).*(n.^4)-(n.^2).*(b.^2-(a.*(b.^2)).^(2/3)+n.^2).*(n.^2)))./(b.^2-(a.*(b.^2)).^(2/3)+n.^2);
=meshgrid(0:0.1:e,-(n+m):0.1:(m+n));
z3=sqrt((sqrt(2.*b.*x3+(-b.^2+(a.*(b.^2)).^(2/3)-n.^2).*(x3.^2)./(n.^2))+m).^2-y3.^2);
mesh(x3,y3,z3); hold on;
=meshgrid(0:0.1:e,-(n+m):0.1:(m+n)); z4=-sqrt((sqrt(2.*b.*x4+(-b.^2+(a.*(b.^2)).^(2/3)-n.^2).*(x4.^2)./(n.^2))+m).^2-y4.^2);
mesh(x4,y4,z4); hold on;
f=(b.*((a.*sqrt((a.*(b.^2)).^(2/3)-n.^2))./((a.*(b.^2)).^(1/3))+(b.*(n.^2))./(b.^2-(a.*(b.^2)).^(2/3)+n.^2)-((n.^2).*sqrt((a.*(b.^2)).^(2/3)-n.^2))./(b.^2-(a.*(b.^2)).^(2/3)+n.^2))-sqrt((a.*b).^2-(b.*(90-m)).^2+2.*n.*(90-m).*(b.^2)-2.*(a.*(b.^2)).^(2/3).*n.*(90-m)-(b.*n).^2-a.*(a.*(b.^2)).^(1/3).*(n.^2)+2.*(a.*(b.^2)).^(2/3).*(n.^2)))./b;
=meshgrid(e:0.1:f,-100:0.1:100);
z5=sqrt(((a.^2-x5.^2+2.*(a.*sqrt((a.*(b.^2)).^(2/3)-n.^2)./(a.*(b.^2)).^(1/3)+b.*(n.^2)./(b.^2-(a.*(b.^2)).^(2/3)+n.^2)-n.^2.*sqrt((a.*(b.^2)).^(2/3)-n.^2)./(b.^2-(a.*(b.^2)).^(2/3)+n.^2)).*x5-(a.*sqrt((a.*(b.^2)).^(2/3)-n.^2)./(a.*(b.^2)).^(1/3)+b.*(n.^2)./(b.^2-(a.*(b.^2)).^(2/3)+n.^2)-n.^2.*sqrt((a.*(b.^2)).^(2/3)-n.^2)./(b.^2-(a.*(b.^2)).^(2/3)+n.^2)).^2).^(1/2)+n-a.*n/(a.*(b.^2)).^(1/3)+m).^2-y5.^2);
mesh(x5,y5,z5); hold on;
=meshgrid(e:0.1:f,-100:0.1:100);
z6=-sqrt(((a.^2-x6.^2+2.*(a.*sqrt((a.*(b.^2)).^(2/3)-n.^2)./(a.*(b.^2)).^(1/3)+b.*(n.^2)./(b.^2-(a.*(b.^2)).^(2/3)+n.^2)-n.^2.*sqrt((a.*(b.^2)).^(2/3)-n.^2)./(b.^2-(a.*(b.^2)).^(2/3)+n.^2)).*x6-(a.*sqrt((a.*(b.^2)).^(2/3)-n.^2)./(a.*(b.^2)).^(1/3)+b.*(n.^2)./(b.^2-(a.*(b.^2)).^(2/3)+n.^2)-n.^2.*sqrt((a.*(b.^2)).^(2/3)-n.^2)./(b.^2-(a.*(b.^2)).^(2/3)+n.^2)).^2).^(1/2)+n-a.*n/(a.*(b.^2)).^(1/3)+m).^2-y6.^2);
mesh(x6,y6,z6); hold on;
=meshgrid(0:0.1:30,-50:0.1:50); z7=50+sqrt(2500-y7.^2); surf(x7,y7,z7); hold on;
=meshgrid(0:0.1:30,-50:0.1:50); z8=50-sqrt(2500-y8.^2); surf(x8,y8,z8); hold on;
=meshgrid(0:0.1:30,-50:0.1:50); z9=-50-sqrt(2500-y9.^2); surf(x9,y9,z9); hold on;
=meshgrid(0:0.1:30,-50:0.1:50); z10=-50+sqrt(2500-y10.^2); surf(x10,y10,z10); hold on;
axis(); axis equal;
set(gca,'XTick',); set(gca,'YTick',[-100:20:100]); set(gca,'ZTick',[-100:20:100]);
ylabel('y轴坐标','FontSize',14); xlabel('x轴坐标','FontSize',14); zlabel('z轴坐标','FontSize',14); title('变焦距曲线三维图','FontSize',14);

[ 本帖最后由 ChaChing 于 2009-3-4 20:35 编辑 ]

fanzhenjie 发表于 2008-8-23 21:42

回复 楼主 fanzhenjie 的帖子

我想得到三维坐标比例一致的图,可是加了axis equal后就显示不全了呢,各位朋友,帮我想想呀,谢谢!不加那句命令能显示完全,但由于X比较小,只是示意图了!

messenger 发表于 2008-8-24 14:57

回复 5楼 fanzhenjie 的帖子

运行了一下你的程序,没有你说的问题呀

能把你显示不全的图形贴出来吗?

fanzhenjie 发表于 2008-8-24 23:22

回复 6楼 messenger 的帖子

谢谢各位关照,已经解决了,把坐标范围扩大,就解决了!

fanzhenjie 发表于 2008-8-26 22:53

大家帮我想想这个程序呀?

大家帮我想想这个程序呀?怎么提取出来一个大的凹面被两个圆环相截,提取出一个圆环中所包围凹面的三维坐标?
我主要是不知道如何控制循环语句!代码如下:
c1=input('请输入A区大半径532/c1时的较小的c1值,赋值到c1:'); if (c1<1)|(c1>6),break;end
c2=input('请输入C区小半径532/c2时的较大的c2值,赋值到c2:'); if (c2<1)|(c2>6),break;end
m=input('请输入最下面C区圆弧口径,范围是25到35,赋值到m:'); if (m<25)|(m>35),break;end
n=input('请输入B区过渡区域口径,范围是10到16,赋值到n:'); if (n<10)|(n>16),break;end
shuipingjiao=input('请输入看三维图时的水平偏角,范围-180到180度,赋值到shuipingjiao:');
yangjiao=input('请输入看三维图时的仰角,范围0到90度,赋值到yangjiao:');
a=523./c1; b=523./c2; d=b-sqrt(b.^2-(-m).^2);
=meshgrid(0:0.06:d,-m:0.06:m); z1=sqrt((m-sqrt(2.*b.*x1-x1.^2)).^2-y1.^2); mesh(x1,y1,z1); hold on;
=meshgrid(0:0.06:d,-m:0.06:m); z2=-sqrt((m-sqrt(2.*b.*x1-x1.^2)).^2-y1.^2); mesh(x2,y2,z2); hold on;
e=(b.*(n.^2)-sqrt((b.^2).*(n.^4)-(n.^2).*(b.^2-(a.*(b.^2)).^(2/3)+n.^2).*(n.^2)))./(b.^2-(a.*(b.^2)).^(2/3)+n.^2);
=meshgrid(0:0.06:e,-(n+m):0.06:(m+n));
z3=sqrt((sqrt(2.*b.*x3+(-b.^2+(a.*(b.^2)).^(2/3)-n.^2).*(x3.^2)./(n.^2))+m).^2-y3.^2); mesh(x3,y3,z3); hold on;
=meshgrid(0:0.06:e,-(n+m):0.06:(m+n));
z4=-sqrt((sqrt(2.*b.*x4+(-b.^2+(a.*(b.^2)).^(2/3)-n.^2).*(x4.^2)./(n.^2))+m).^2-y4.^2); mesh(x4,y4,z4); hold on;
f=(b.*((a.*sqrt((a.*(b.^2)).^(2/3)-n.^2))./((a.*(b.^2)).^(1/3))+(b.*(n.^2))./(b.^2-(a.*(b.^2)).^(2/3)+n.^2)-((n.^2).*sqrt((a.*(b.^2)).^(2/3)-n.^2))./(b.^2-(a.*(b.^2)).^(2/3)+n.^2))-sqrt((a.*b).^2-(b.*(100-m)).^2+2.*n.*(100-m).*(b.^2)-2.*(a.*(b.^2)).^(2/3).*n.*(100-m)-(b.*n).^2-a.*(a.*(b.^2)).^(1/3).*(n.^2)+2.*(a.*(b.^2)).^(2/3).*(n.^2)))./b;
=meshgrid(e:0.06:f,-100:0.06:100);
z5=sqrt(((a.^2-x5.^2+2.*(a.*sqrt((a.*(b.^2)).^(2/3)-n.^2)./(a.*(b.^2)).^(1/3)+b.*(n.^2)./(b.^2-(a.*(b.^2)).^(2/3)+n.^2)-n.^2.*sqrt((a.*(b.^2)).^(2/3)-n.^2)./(b.^2-(a.*(b.^2)).^(2/3)+n.^2)).*x5-(a.*sqrt((a.*(b.^2)).^(2/3)-n.^2)./(a.*(b.^2)).^(1/3)+b.*(n.^2)./(b.^2-(a.*(b.^2)).^(2/3)+n.^2)-n.^2.*sqrt((a.*(b.^2)).^(2/3)-n.^2)./(b.^2-(a.*(b.^2)).^(2/3)+n.^2)).^2).^(1/2)+n-a.*n/(a.*(b.^2)).^(1/3)+m).^2-y5.^2);
mesh(x5,y5,z5); hold on;
=meshgrid(e:0.06:f,-100:0.06:100);
z6=-sqrt(((a.^2-x6.^2+2.*(a.*sqrt((a.*(b.^2)).^(2/3)-n.^2)./(a.*(b.^2)).^(1/3)+b.*(n.^2)./(b.^2-(a.*(b.^2)).^(2/3)+n.^2)-n.^2.*sqrt((a.*(b.^2)).^(2/3)-n.^2)./(b.^2-(a.*(b.^2)).^(2/3)+n.^2)).*x6-(a.*sqrt((a.*(b.^2)).^(2/3)-n.^2)./(a.*(b.^2)).^(1/3)+b.*(n.^2)./(b.^2-(a.*(b.^2)).^(2/3)+n.^2)-n.^2.*sqrt((a.*(b.^2)).^(2/3)-n.^2)./(b.^2-(a.*(b.^2)).^(2/3)+n.^2)).^2).^(1/2)+n-a.*n/(a.*(b.^2)).^(1/3)+m).^2-y6.^2);
mesh(x6,y6,z6); hold on;
=meshgrid(0:0.1:30,-50:0.1:50); z7=50+sqrt(2500-y7.^2); surf(x7,y7,z7); hold on;
=meshgrid(0:0.1:30,-50:0.1:50); z8=50-sqrt(2500-y8.^2); surf(x8,y8,z8); hold on;
=meshgrid(0:0.1:30,-50:0.1:50); z9=-50-sqrt(2500-y9.^2); surf(x9,y9,z9); hold on;
=meshgrid(0:0.1:30,-50:0.1:50); z10=-50+sqrt(2500-y10.^2); surf(x10,y10,z10); hold on;
pianjiao=atan((f-d)./100);
axis();
set(gca,'XTick',); set(gca,'YTick',[-100:20:100]); set(gca,'ZTick',[-100:20:100]);
axis equal; view();
ylabel('y轴坐标','FontSize',14); xlabel('x轴坐标','FontSize',14); zlabel('z轴坐标','FontSize',14); title('变焦距曲线三维图','FontSize',14);

[ 本帖最后由 ChaChing 于 2009-3-4 20:48 编辑 ]
页: [1]
查看完整版本: 请教:如何控制坐标按相同的比例显示axis equal写进去后图形就显示不全了!急