06.08.2013 Views

内容简介作者简介 - 科学与工程计算系

内容简介作者简介 - 科学与工程计算系

内容简介作者简介 - 科学与工程计算系

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

subplot(1,3,2),exm07052_1(r1,r2,'Marker','o')<br />

subplot(1,3,3),exm07052_1(r1,r2,'LineWidth',5,'Color',[1 0.4 0])<br />

0.5<br />

-0.5<br />

7.5.3 跨空间变量传递<br />

1<br />

0<br />

-1<br />

-1 0 1<br />

-0.5<br />

7.5.3.1 跨空间计算串表达式的值<br />

1<br />

0.5<br />

0<br />

-1<br />

-1 0 1<br />

图 7.5-1<br />

7<br />

1<br />

0.5<br />

0<br />

-0.5<br />

-1<br />

-1 0 1<br />

【例 7.5.3.1-1】本例演示:(A)编写绘制正多边形或圆的程序。(B)子函数与(母)函<br />

数的关系。(C)各种不同的工作空间。(D)evalin 运行机理与 eval 的异同。<br />

(1)<br />

[exm070531_1.m]<br />

function y1=exm070531_1(a,s)<br />

t=(0:a)/a*2*pi;<br />

y1=subevalinzzy(4,s);<br />

%------------ subfunction -------------<br />

function y2=subevalinzzy(a,s)<br />

t=(0:a)/a*2*pi;ss='a*exp(i*t)';<br />

switch s<br />

case {'base','caller'}<br />

y2=evalin(s,ss);<br />

case 'self'<br />

y2=eval(ss);<br />

end<br />

(2)<br />

clear,a=30;t=(0:a)/a*2*pi;sss={'base','caller','self'};<br />

for k=1:3<br />

y0=exm070531_1(8,sss{k});<br />

subplot(1,3,k)<br />

plot(real(y0),imag(y0),'r','LineWidth',3),axis square image<br />

end

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!