catherin
2008-09-03, 21:37
关于界面中函数调用的问题
这是做的一个界面 ,在上面输入a,b调用下面个函数llsystem 得到图形,现在问题是没有图形出来????????急急急急:cry: :cry: :cry: :cry: :cry:
clf reset
H=axes('unit','normalized','position',[0,0,1,1],'visible','off');
set(gcf,'currentaxes',H);
str='\fontname{隶书} 连续时间系统的冲激和阶跃响应曲线';
text(0.12,0.93,str,'fontsize',13);
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 15],'ylim',[0 1.8],'fontsize',8);
h_text=uicontrol(h_fig,'style','text',...
'unit','normalized','position',[0.67,0.73,0.25,0.14],...
'horizontal','left','string',{'输入系数','a='});
h_edit1=uicontrol(h_fig,'style','edit',...
'unit','normalized','position',[0.67,0.59,0.25,0.14],...
'horizontal','center','Back',[0,1,0])
h_text=uicontrol(h_fig,'style','text',...
'unit','normalized','position',[0.67,0.45,0.25,0.14],...
'horizontal','left','string',{'输入系数','b='});
h_edit2=uicontrol(h_fig,'style','edit',...
'unit','normalized','position',[0.67,0.30,0.25,0.14],...
'horizontal','center','Back',[0,1,0])
COMM=[ 'a=str2num(get(h_edit1;''string''));',...
'b=str2num(get(h_edit2;''string''));','llsystem(a,b);'];
uicontrol(h_fig,'Style','Push','Position',[0.67,0.1,0.1,0.1],...
'String','运行','Units','normalized','Call',COMM);
function [h,s]=llsystem(a,b)
t=0:0.01:10;
sys=tf(b,a);
h=impulse(sys,t);
s=step(sys,t);
subplot(121);
plot(t,h,'y');
title( '冲激响应' );
xlabel( 't(单位:s)');
subplot(122);
plot(t,s,'m');
title('阶跃响应');
xlabel( 't(单位:s)');
这是做的一个界面 ,在上面输入a,b调用下面个函数llsystem 得到图形,现在问题是没有图形出来????????急急急急:cry: :cry: :cry: :cry: :cry:
clf reset
H=axes('unit','normalized','position',[0,0,1,1],'visible','off');
set(gcf,'currentaxes',H);
str='\fontname{隶书} 连续时间系统的冲激和阶跃响应曲线';
text(0.12,0.93,str,'fontsize',13);
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 15],'ylim',[0 1.8],'fontsize',8);
h_text=uicontrol(h_fig,'style','text',...
'unit','normalized','position',[0.67,0.73,0.25,0.14],...
'horizontal','left','string',{'输入系数','a='});
h_edit1=uicontrol(h_fig,'style','edit',...
'unit','normalized','position',[0.67,0.59,0.25,0.14],...
'horizontal','center','Back',[0,1,0])
h_text=uicontrol(h_fig,'style','text',...
'unit','normalized','position',[0.67,0.45,0.25,0.14],...
'horizontal','left','string',{'输入系数','b='});
h_edit2=uicontrol(h_fig,'style','edit',...
'unit','normalized','position',[0.67,0.30,0.25,0.14],...
'horizontal','center','Back',[0,1,0])
COMM=[ 'a=str2num(get(h_edit1;''string''));',...
'b=str2num(get(h_edit2;''string''));','llsystem(a,b);'];
uicontrol(h_fig,'Style','Push','Position',[0.67,0.1,0.1,0.1],...
'String','运行','Units','normalized','Call',COMM);
function [h,s]=llsystem(a,b)
t=0:0.01:10;
sys=tf(b,a);
h=impulse(sys,t);
s=step(sys,t);
subplot(121);
plot(t,h,'y');
title( '冲激响应' );
xlabel( 't(单位:s)');
subplot(122);
plot(t,s,'m');
title('阶跃响应');
xlabel( 't(单位:s)');