⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jincou.m

📁 matlab 遗传算法的程序
💻 M
📖 第 1 页 / 共 2 页
字号:
TextHeight = Frame1Position(4) - TabSpace * 2 ;
TextPosition = [TextXPos  TextYPos  TextWidth  TextHeight] ;
% subtitle:
TextHandle = uicontrol(FigureHandle, 'Style','text', 'Units','pixels',...
    'position',[50 240 130 30], 'Horizontal','left',...
    'string', {['B点  x轴上下界']}, 'fontsize',12 );
edit3 = uicontrol(FigureHandle, 'Style', 'edit', 'Units','pixels',...
        'position', [50 200 130 30], 'Horizontal','left', 'BackgroundColor', [1 1 1], ...
        'Tag','edit3' , ...
        'String', 0, 'FontSize',10, ...
        'Callback', ['jincou(''edit3_Callback'',gcbo)'] ) ;
TextXPos = Frame1Position(1) + TabSpace +200 ;
TextYPos = Frame1Position(2) + TabSpace -100 ;
TextWidth = Frame1Position(3) - TabSpace * 2 ;
TextHeight = Frame1Position(4) - TabSpace * 2 ;
TextPosition = [TextXPos  TextYPos  TextWidth  TextHeight] ;
% subtitle:
TextHandle = uicontrol(FigureHandle, 'Style','text', 'Units','pixels',...
    'position',[250 240 130 30], 'Horizontal','left',...
    'string', {['B点  y轴上下界']}, 'fontsize',12 );
edit4 = uicontrol(FigureHandle, 'Style', 'edit', 'Units','pixels',...
        'position', [250 200 130 30], 'Horizontal','left', 'BackgroundColor', [1 1 1], ...
        'Tag','edit4' , ...
        'String', 0, 'FontSize',10, ...
        'Callback', ['jincou(''edit4_Callback'',gcbo)'] ) ;
    
        

 TextHandle = uicontrol(FigureHandle, 'Style','text', 'Units','pixels',...
    'position',[50 90 400 30], 'Horizontal','left',...
    'string', {['紧凑型约束: Cx  Cy  Bx  By ']}, 'fontsize',13 );
    

ButtonWidth = 80 ;
ButtonHeight = 25 ;
ButtonXPos = FigureWidth - ButtonWidth - TabSpace * 3 ;
ButtonYPos = TabSpace * 2 ;;
ButtonPosition = [ButtonXPos  ButtonYPos  ButtonWidth  ButtonHeight] ;
% generate the pushbutton: Close .
ButtonHandle = uicontrol( 'Parent', FigureHandle, 'Units', 'Pixels', 'Position', ButtonPosition, ...
    'Style', 'pushbutton', 'string', '关闭', 'Fontsize',12, 'Callback', ['jincou(''close_Callback'',gcbo)'] ) ;


handles = guihandles( FigureHandle ) ;
guidata( FigureHandle, handles ) ;




% --------------------------------------------------------------------------
function  init_FigureContent( h )
       
handles = guidata( h ) ;

T_SimulationData = getappdata( handles.jincou, 'T_SimulationData' ) ;

% open the next figure .

if isempty( T_SimulationData )
    T_SimulationData = T_Youhua( 'Get_DefaultT_SimulationData' ) ;    
    % save the data .
   
end

set(handles.edit1,'string',num2str(T_SimulationData.C_x));
set(handles.edit2,'string',num2str(T_SimulationData.C_y));
set(handles.edit3,'string',num2str(T_SimulationData.B_x));
set(handles.edit4,'string',num2str(T_SimulationData.B_y));

% --------------------------------------------------------------------------






% --------------------------------------------------------------------------
function  edit1_Callback( h )
       
handles = guidata( h ) ;
% get the T_SimulationData .
T_SimulationData = getappdata( handles.jincou, 'T_SimulationData' ) ;
C_x = get(handles.edit1, 'String');
if ~isstr(C_x)
    set(handles.edit1, 'String', 0);
    errordlg('Input must be a string','Error');
end
T_SimulationData.C_x=str2num(C_x);
setappdata( handles.jincou, 'T_SimulationData', T_SimulationData ) ;


% --------------------------------------------------------------------------
function  edit2_Callback( h )
       
handles = guidata( h ) ;
% get the T_SimulationData .
T_SimulationData = getappdata( handles.jincou, 'T_SimulationData' ) ;
C_y = get(handles.edit2, 'String');
if ~isstr(C_y)
    set(handles.edit2, 'String', 0);
    errordlg('Input must be a string','Error');
end
T_SimulationData.C_y=str2num(C_y);
setappdata( handles.jincou, 'T_SimulationData', T_SimulationData ) ;

%---------------------------------------------------------------
% --------------------------------------------------------------------------
function  edit3_Callback( h )
       
handles = guidata( h ) ;
% get the T_SimulationData .
T_SimulationData = getappdata( handles.jincou, 'T_SimulationData' ) ;
B_x = get(handles.edit3, 'String');
if ~isstr(B_x)
    set(handles.edit3, 'String', 0);
    errordlg('Input must be a string','Error');
end
T_SimulationData.B_x=str2num(B_x);
setappdata( handles.jincou, 'T_SimulationData', T_SimulationData ) ;


% --------------------------------------------------------------------------
function  edit4_Callback( h )
       
handles = guidata( h ) ;
% get the T_SimulationData .
T_SimulationData = getappdata( handles.jincou, 'T_SimulationData' ) ;
B_y = get(handles.edit4, 'String');
if ~isstr(B_y)
    set(handles.edit4, 'String', 0);
    errordlg('Input must be a string','Error');
end
T_SimulationData.B_y=str2num(B_y);
setappdata( handles.jincou, 'T_SimulationData', T_SimulationData ) ;
%--------------------------------------------------------------------------


function  LoadData_Callback( h )
       
handles = guidata( h ) ;


PromptString = '选择数据文件.' ;
WarningString1 = '文件格式出错。 ' ;
WarningString2 = '选择的文件不是正确的数据文件。 ' ;


[ FileName , PathName ] = uigetfile( {'*.mat','数据文件(*.mat)'}, PromptString ) ;


if FileName == 0
    return ;    
else
    
    [TempPathName, FileName, FileTypeName, Version] = fileparts( FileName ) ;

    if ~strcmp( FileTypeName, '.mat' ) ;
        warndlg( WarningString1, '警告', 'modal' ) ;
        return ;
    end
    SaveFile = fullfile( PathName, [FileName, FileTypeName, Version] ) ;
end

T_SimulationData = [] ;
try
    load( SaveFile, 'T_SimulationData' ) ;
catch
end

if isempty( T_SimulationData ) | ~isstruct( T_SimulationData );
 
    
    warndlg( WarningString1, '警告', 'modal' ) ;
    return ;
end


% save the data .
setappdata( handles.jincou, 'T_SimulationData', T_SimulationData ) ;

% display the new data .
init_FigureContent( h ) ;




% --------------------------------------------------------------------------
function  SaveData_Callback( h )
       
handles = guidata( h ) ;

% get the T_SimulationData .
T_SimulationData = getappdata( handles.jincou, 'T_SimulationData' ) ;


PromptString = '保存数据文件.' ;
MessageString = '保存数据文件成功。 ' ;

[ FileName , PathName ] = uiputfile( {'*.mat','数据文件(*.mat)'}, PromptString ) ;


if FileName == 0
    return ;    
else
    
    [TempPathName, FileName, FileTypeName, Version] = fileparts( FileName ) ;

    if ~strcmp( FileTypeName, '.mat' ) ;
        FileTypeName = '.mat' ;
    else
    end
    SaveFile = fullfile( PathName, [FileName, FileTypeName, Version] ) ;
end

% save the result  file .
save( SaveFile, 'T_SimulationData' ) ;


msgbox( MessageString ) ;




% --------------------------------------------------------------------------

function  close_Callback( h )
       
handles = guidata( h ) ;




% get the T_SimulationData .
T_SimulationData = getappdata( handles.jincou, 'T_SimulationData' ) ;

% open the next figure .

if isempty( T_SimulationData )
    T_SimulationData = T_Youhua( 'Get_DefaultT_SimulationData' ) ;    
    % save the data .
   
end


Youhua( T_SimulationData ) ;

% close the current figure .
pause(0) ;
close( handles.jincou ) ;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -