马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?我要加入
x
最近解一个耦合方程,做一个简单的界面,但是在最后一步出现了一点计算结果显示方面的问题,在论坛里搜索了一下相关的东西,没找到解决途径。
以下是程序部分:
H=axes('unit','normalized','position',[0,0,1,1],'visible','off');
h_fig=get(H,'parent');
h_text1=uicontrol(h_fig,'style','text',...
'unit','normalized','position',[0.25,0.7,0.18,0.085],...
'horizontal','left','string',{'Fiber Length(Km)'},...
'background','w',...
'fontsize',10);
h_edit1=uicontrol(h_fig,'style','edit',...
'unit','normalized','position',[0.61,0.7,0.18,0.085],...
'background','w',...
'callback',[...
'Length=str2num(get(gcbo,''string''));']);
h_text2=uicontrol(h_fig,'style','text',...
'unit','normalized','position',[0.25,0.55,0.18,0.085],...
'horizontal','left','string',{'Pump in(mW)'},...
'background','w',...
'fontsize',10);
h_edit2=uicontrol(h_fig,'style','edit',...
'unit','normalized','position',[0.61,0.55,0.18,0.085],...
'background','w',...
'callback',[...
'Pump=str2num(get(gcbo,''string''));']);
h_text3=uicontrol(h_fig,'style','text',...
'unit','normalized','position',[0.25,0.4,0.18,0.085],...
'horizontal','left','string',{'Signal in(mW)'},...
'background','w',...
'fontsize',10);
h_edit3=uicontrol(h_fig,'style','edit',...
'unit','normalized','position',[0.61,0.4,0.18,0.085],...
'background','w',...
'callback',[...
'Signal=str2num(get(gcbo,''string''));',...
'options = odeset(''RelTol'',1e-4,''AbsTol'',[1e-4 1e-4]);',...
'[T,Y] = ode45(@rigid,[0:Length],[Pump Signal],options);',...
'z=0:Length;',...
'x=Signal*exp(-0.19*z''/4.343);',...
'Gain=10*log10(Y(Length+1,2)/x(Length+1))']);
h_edit4=uicontrol(h_fig,'style','edit',...
'unit','normalized','position',[0.25,0.24,0.54,0.1],...
'background','w');
calculate=['Gain=10*log10(Y(Length+1,2)/x(Length+1));'];
h_button=uicontrol(h_fig,'style','push',...
'unit','normalized','position',[0.25,0.15,0.54,0.06],...
'background','w',...
'string','calculate');
set(h_edit4,num2str(Gain))
界面如附件所示。
要实现的功能:在前三个edit只能过输入数据后,点击“calculate”后,要在edit4中显示对应的计算结果。
出现的问题是:
运行程序后可以显示结果,但是显示的是前一组数据的,当我改变输入的数据后,可以在命令窗中显示结果,但是在界面上的edit4中无法更新。
期待高手赐教,谢谢。
[ 本帖最后由 向北飞 于 2009-4-19 17:20 编辑 ] |