|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
x
编写程序如下:
clf reset
H=axes('unit','normalized','position',[0,0,1,1],'visible','off');
set(gcf,'currentaxes',H);
str='阶跃图';
text(0.1,0.9,str,'fontsize',12);
h_fig=get(H,'parent');
set(h_fig,'unit','normalized','position',[0.1,0.2,0.7,0.4]);
h_axes=axes('parent',h_fig,'unit','normalized','position',...
[0.1,0.15,0.55,0.7],'xlim',[0,20],'ylim',[-2,2],'fontsize',8);
num=1;
den=[1 2 1];
t=0:0.1:20;
y=step(num,den,t);
plot(t,y);
h_text1=uicontrol(h_fig,'style','text','unit','normalized',...
'position',[0.67,0.73,0.25,0.14],'horizontal','left',...
'string',{'分子','num'});
h_edit1=uicontrol(h_fig,'style','edit','unit','normalized',...
'max',10,...
'position',[0.67,0.59,0.25,0.14],'horizontal','left','max',10);
h_text2=uicontrol(h_fig,'style','text','unit','normalized',...
'position',[0.67,0.45,0.25,0.14],'horizontal','left',...
'string',{'分母','den'});
h_edit2=uicontrol(h_fig,'style','edit','unit','normalized',...
'max',10,...
'position',[0.67,0.34,0.25,0.14],'horizontal','left','max',10);
hb1=uicontro(h_fig,'style','push','unit','normalized',...
'position',[ 0.67 0.23 0.25 0.11],'horizontal','left',...
'string','开始');
set(h_edit1,'callback',[...
'num=str2num(get(gcbo,''string''));'...
]);
set(h_edit1,'callback',[...
'den=str2num(get(gcbo,''string''));'...
]);
set(hb1,'callback',[...
'callstep(h_edit1,num,h_edit2,den)']);
%回调函数
function callstep(h_edit1,num,h_edit2,den)
cla,
t=0:0.1:20;
y=step(num,den,t);
plot(t,y)
问:为什么分子num输入1;分母输入[1 0.2 1]时,不能正常回调显示呢?
|
|