马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?我要加入
x
function varargout = myfit( varargin )<BR> % clf reset<BR> FigureHandle = figure( 'Visible', 'on' ) ;<BR> set( FigureHandle, 'Units' , 'normalized', 'Position', [0.2 0.2 0.75 0.6], ...<BR> 'Name', 'Curve Fitting Program', ...<BR> 'Tag', 'T_youhua', ...<BR> 'FileName' , '' ,...<BR> 'MenuBar' , 'none' ,...<BR> 'NumberTitle' , 'off' ,...<BR> 'Resize', 'off', ...<BR> 'windowstyle', 'normal') ; <BR> <BR> generate_MenuContent( FigureHandle ) ;<BR> generate_FigureContent( FigureHandle ) ;<BR> set( FigureHandle, 'Visible', 'on' ) ; <BR> <BR> % ------------------------------------------------------------<BR><BR>function generate_MenuContent( FigureHandle ) ;<BR><BR>% generate the file menu .<BR>% ------------------------------------------------------------<BR>MenuHandle = uimenu( 'Parent', FigureHandle, 'Label', 'File (&F)' ) ;<BR><BR>% define the parameters of the menus .<BR>MenuLabel = { 'Open (&O)'; 'Exit (&E)' } ;<BR><BR>% add Polygon <BR>MenuTag = { 'MenuOpenHistory'; 'MenuClose' } ;<BR>MenuCallback = { ...<BR> ['myfit( ''MenuOpenHistory_Callback11'', gcbf)']; ...<BR> ['close all;'] } ;<BR>SeparatorGroup = { 'off'; 'on' } ;<BR><BR>% generate the uimenus of file .<BR>for num = 1: length( MenuTag )<BR>% for num = 2<BR> UimenuHandle(num) = uimenu( MenuHandle ) ;<BR> set( UimenuHandle(num), 'Tag' , MenuTag{num} , ...<BR> 'Callback' , MenuCallback{num} , ...<BR> 'Label' , MenuLabel{num} , ...<BR> 'Separator', SeparatorGroup{num} ) ;<BR>end<BR><BR>% ---------------------------------------------------<BR>function generate_FigureContent( FigureHandle ) ;<BR><BR> h_push1 = uicontrol(FigureHandle,'style','push','unit','normalized', ...<BR> 'position',[0.70 0.23 0.10 0.08], 'string','grid on',...<BR> 'Fontsize',12,'callback','grid on');<BR><BR> h_push1 = uicontrol(FigureHandle,'style','push','unit','normalized', ...<BR> 'position',[0.70 0.15 0.10 0.08], 'string','grid off',...<BR> 'Fontsize',12,'callback','grid off');<BR><BR><BR>% --------------------------------------------------------------------------<BR>function MenuOpenHistory_Callback( h )<BR> <BR> handles = guidata( h ) ;<BR><BR> PromptString = '选择数据文件.' ;<BR> WarningString1 = '文件格式出错。 ' ;<BR> WarningString2 = '选择的文件不是正确的数据文件。 ' ;<BR><BR> [ FileName , PathName ] = uigetfile( {'*.mat','数据文件(*.mat)'}, PromptString ) ;<BR><BR><BR> if FileName == 0<BR> return ; <BR> else<BR> <BR> [TempPathName, FileName, FileTypeName, Version] = fileparts( FileName ) ;<BR><BR> if ~strcmp( FileTypeName, '.mat' ) ;<BR> warndlg( WarningString1, '警告', 'modal' ) ;<BR> return ;<BR> end<BR> SaveFile = fullfile( PathName, [FileName, FileTypeName, Version] ) ;<BR> end<BR><BR> T_SimulationData = [] ;<BR> try<BR> load( SaveFile, 'T_SimulationData' ) ;<BR> catch<BR> end<BR><BR> if isempty( T_SimulationData ) | ~isstruct( T_SimulationData );<BR><BR> <BR> warndlg( WarningString1, '警告', 'modal' ) ;<BR> return ;<BR>end<BR><BR><BR>% save the data .<BR>setappdata( handles.myfit, 'T_SimulationData', T_SimulationData ) ; |