改变坐标轴范围!!
h0=figure('toolbar','none', 'position',, 'name','实例4');h1=axes('parent',h0, 'position',, 'visible','on');
e1=uicontrol('parent',h0, 'style','edit', 'string',1, 'position',);
t1=uicontrol('parent',h0, 'style','text', 'string','X轴最小值', 'position',);
e2=uicontrol('parent',h0, 'style','edit', 'string',5, 'position',);
t2=uicontrol('parent',h0, 'style','text', 'string','X轴最大值', 'position',);
e3=uicontrol('parent',h0, 'style','edit', 'string',1, 'position',);
t3=uicontrol('parent',h0, 'style','text', 'string','Y轴最小值', 'position',);
e4=uicontrol('parent',h0, 'style','edit', 'string',5, 'position',);
t4=uicontrol('parent',h0, 'style','text', 'string','Y轴最大值', 'position',);
e5=uicontrol('parent',h0, 'style','edit', 'string',20, 'position',);
t5=uicontrol('parent',h0, 'style','text', 'horizontalalignment','left', 'string','点数', 'position',);
b1=uicontrol('parent',h0, 'style','pushbutton', 'string','绘图', 'position',, ...
'callback',[ 'a=str2num(get(e1,''string'')); b=str2num(get(e2,''string''));,',...
'c=str2num(get(e3,''string'')); d=str2num(get(e4,''string'')); n=str2num(get(e5,''string''));,',...
'xgrid=linspace(-abs(a),abs(a),n); ygrid=linspace(-abs(b),abs(b),n);',...
'=meshgrid(xgrid,ygrid); z=c*sqrt(d-y.*y/b/b-x.*x/a/a); u=1; z1=real(z);', ...
'for k=2:n-1, for j=2:n-1, if imag(z(k,j))~=0, z1(k,j)=0; end;',...
'if all(imag(z(,)))~=0, z1(k,j)=nan; end; end; end;',...
'surf(x,y,z1); hold on, if u==1, z2=-z1; surf(x,y,z2),',...
'axis([-abs(a),abs(a),-abs(b),abs(b),-abs(c),abs(c)]); end;',...
'xlabel(''x''); ylabel(''y''); zlabel(''z''); hold off']);
b2=uicontrol('parent',h0, 'style','pushbutton', 'string','关闭', 'position',, 'callback','close');
[ 本帖最后由 ChaChing 于 2009-12-28 14:45 编辑 ] 能不能稍微解释一下啊! 原帖由 wangyongq246 于 2006-11-16 16:21 发表
能不能稍微解释一下啊!
这个程序好像没有太多需要解释的,代码很清晰
页:
[1]