实验4、matlab的计算可视化和GUI设计

合集下载
相关主题
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

p345

subplot(2,2,1)

t1=0:0.1:2;

y1=sin(2*pi*t1);

plot(t1,y1);

title('y=sin(2\pit)')

练习:

subplot(2,2,2)

t2=0:0.1:2;

y2=[exp(-t2);exp(-2*t2);exp(-3*t2)]; plot(t2,y2)

axis([0 2 -0.2 1.2]);

title('y=e-t,y=e-2t,y=e-3t')

练习:

subplot(2,2,3);

t3=[0 1 1 2 2 3 4]; y3=[0 0 2 2 0 0 0]; plot(t3,y3);

axis([0 4 -0.5 3]); title('脉冲信号')

练习:

subplot(2,2,4);

t4=0:0.1:2*pi;

plot(sin(t4),cos(t4));

axis([-1.2 1.2 -1.2 1.2]);

axis equal;

title('圆')

练习:

P346

x=0:0.1:20;

zeta=0

y1=1-1/sqrt(1-zeta^2)*exp(-zeta*x).*sin(sqrt( 1-zeta^2)*x+acos(zeta));

plot(x,y1)

zeta=0.3;

y2=1-1/sqrt(1-zeta^2)*exp(-zeta*x).*sin(sqrt( 1-zeta^2)*x+acos(zeta));

hold on

plot(x,y2,'r:')

zeta=0.5;

y3=1-1/sqrt(1-zeta^2)*exp(-zeta*x).*sin(sqrt( 1-zeta^2)*x+acos(zeta));

plot(x,y3,'g*')

zeta=0.707;

y4=1-1/sqrt(1-zeta^2)*exp(-zeta*x).*sin(sqrt( 1-zeta^2)*x+acos(zeta));

plot(x,y4,'m-')

title('二阶系统曲线')

legend('\zeta=0','\zeta=0.3','\zeta=0.5','\zeta=0. 707')

grid on

gtext('\zeta=0')

gtext('\zeta=0.3')

gtext('\zeta=0.5')

gtext('\zeta=0.707')

ginput(3)

zeta =

ans =

2.6037 0.9035

13.1106 2.0029

4.2166 1.0380

P347

h_fig=gcf

h_axis=gca

h_line1=gco

h_title=get(gca,'title')

h_text2=findobj(h_fig,'string','\zeta=0.3') h_fig =

1

h_axis =

151.0018

h_line1 =

1

h_title =

152.0018

h_text2 =

Empty matrix: 0-by-1

set(h_line1,'linewidth',5)

set(h_axis,'xgrid','off')

set(gca,'ytick',[0 0.25 0.5 1.0 1.25 1.5 1.75 2.0])

set(h_title,'color','red','fontsize',13)

set(h_text2,'color','red')

??? Undefined function or variable 'h_axis'.

P349

x=0:0.1:20;

y1=1-1/sqrt(1-zeta^2)*exp(-zeta*x).*sin(sqrt( 1-zeta^2)*x+acos(zeta));

y2=1-1/sqrt(1-zeta^2)*exp(-zeta*x).*sin(sqrt( 1-zeta^2)*x+acos(zeta));

y3=1-1/sqrt(1-zeta^2)*exp(-zeta*x).*sin(sqrt( 1-zeta^2)*x+acos(zeta));

y4=1-1/sqrt(1-zeta^2)*exp(-zeta*x).*sin(sqrt( 1-zeta^2)*x+acos(zeta));

y=[y1;y2;y3;y4];

z=[ones(size(x))*0;ones(size(x))*0.3;ones(siz e(x))*0.5;ones(size(x))*0.707];

plot(x,x,x,x)

surf(x,x,x,x)

??? Input argument "n" is undefined.

Error in ==> zeta at 12

Z = double(zeta(sym(n),sym(X)));

P350

x=0:0.3:2*pi;

y=sin(x);

subplot(2,2,1)

bar(x,y,0.5)

axis([0,2*pi,-1.2,1.2])

subplot(2,2,2)

fill(x,y,'r')

subplot(2,2,3)

stairs(x,y)

subplot(2,2,4)

stem(x,y)

P350

guide

相关文档
最新文档