本程序要实现的功能是,从菜单栏打开任意一个文本文件,画图并求最大值和最小值,
可是我的程序在选择了文件后,最大值和最小值以及图都不能刷新,只有再次运行程序才能得到结果,请高手们帮忙看一下,该怎么修改,小女不甚感激!.m文件如下:
yWin=figure('toolbar','none','Menubar','none','Position',[150,150,700,500],'Name','MATLAB仿真建模',
'Resize','on','pointer','custom','numbertitle','off','color','m');
ymenu001=uimenu(yWin,'label','File');
ymenu0011=uimenu(ymenu001,'label','File
Open');
ymenu002=uimenu(yWin,'label','Grid');
ymenu0021=uimenu(ymenu002,'label','Grid
on','callback','Grid on');
ymenu0021=uimenu(ymenu002,'label','Grid
off','callback','Grid off');
ymenu003=uimenu(yWin,'label','Axes');
ymenu0031=uimenu(ymenu003,'label','Axes
on','callback','set(gca,''visible'',''on'')');
ymenu0031=uimenu(ymenu003,'label','Axes
off','callback','set(gca,''visible'',''off'')');
%set(0,'defaultaxeslinestyleorder','-|--|-.')
%set(0,'defaultaxescolororder',[0
0 0])
yAxes=axes('Box','on','Units','points','Position',[200,50,260,300]);
%plot(t,data);%,
legend('Location 1','Location 2','Location 3',0)
xlabel('Time'), ylabel('Vehicle
Count'), grid on
pushbutton1=uicontrol(yWin,'style','push','tag','tag_calc_push','Position',[20,120,180,50],'String','Max:','FontSize',12,'BackGroundColor','y','ForeGroundColor','r');%,...
%'Callback',['Max=max(data)']);
pushbutton2=uicontrol(yWin,'style','pushbutton','Position',[20,240,180,50],'String','Min
:','FontSize',12,'BackGroundColor','y','ForeGroundColor','r');%,...
%'Callback',['Min=min(data)']);
pushbutton3=uicontrol(yWin,'style','pushbutton','Position',[20,370,180,50],'String','Average
:','FontSize',12,'BackGroundColor','y','ForeGroundColor','r');%,...
%'Callback',['Average=mean(data)']);
haedit1 =
uicontrol(yWin,'style','edit','tag','tag_Max_edit',
'FontSize',10,'position',[20 80 180
30]);%,'callback',['set(haedit1,''string'',num2str(Max)))']);
haedit2 =
uicontrol(yWin,'style','edit','tag','tag_a_edit', 'FontSize',10,'position',[20
200 180 30]);
haedit3 =
uicontrol(yWin,'style','edit','tag','tag_a_edit', 'FontSize',10,'position',[20
330 180 30]);
global fname fpath
selectfile=[...
'[fname,fpath,filterindex]=uigetfile({''*.txt''},''select
file'');,'...
'if(filterindex==0),'...
'return;,'...
'end'];
set(ymenu0011,'callback',selectfile);
%set(haedit1,'string',[]);
%set(haedit2,'string',[]);
%set(haedit3,'string',[]);
fid=fopen(fname);
[data,count]=fscanf(fid,'%d');
t=1:count;
h=plot(t,data);
mu=num2str(max(data));
set(pushbutton1,'callback','set(haedit1,''string'',mu)');
mn=num2str(min(data));
set(pushbutton2,'callback','set(haedit2,''string'',mn)');
av=num2str(mean(data));
set(pushbutton3,'callback','set(haedit3,''string'',av)');