天天看點

matlab重新整理網頁,[求助]如何重新整理資料

[求助]如何重新整理資料

本程式要實作的功能是,從菜單欄打開任意一個文本檔案,畫圖并求最大值和最小值,

可是我的程式在選擇了檔案後,最大值和最小值以及圖都不能重新整理,隻有再次運作程式才能得到結果,請高手們幫忙看一下,該怎麼修改,小女不甚感激!

.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)');