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

📄 identga.m

📁 基于GA(遗传算法)的ARX模型参数辨识
💻 M
📖 第 1 页 / 共 2 页
字号:

% Hints: get(hObject,'String') returns contents of in as text27
%        str2double(get(hObject,'String')) returns contents of in as a double


% --- Executes during object creation, after setting all properties.
function in_CreateFcn(hObject, eventdata, handles)
% hObject    handle to in (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end




% --- Executes on button press in error.
function error_Callback(hObject, eventdata, handles)
% hObject    handle to error (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of error





function Aleast_Callback(hObject, eventdata, handles)
% hObject    handle to Aleast (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of Aleast as text27
%        str2double(get(hObject,'String')) returns contents of Aleast as a double


% --- Executes during object creation, after setting all properties.
function Aleast_CreateFcn(hObject, eventdata, handles)
% hObject    handle to Aleast (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function Bleast_Callback(hObject, eventdata, handles)
% hObject    handle to Bleast (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of Bleast as text27
%        str2double(get(hObject,'String')) returns contents of Bleast as a double


% --- Executes during object creation, after setting all properties.
function Bleast_CreateFcn(hObject, eventdata, handles)
% hObject    handle to Bleast (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


% --- Executes on button press in show_real_output.
function show_real_output_Callback(hObject, eventdata, handles)
% hObject    handle to show_real_output (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of show_real_output
try
    real_plot = get(handles.show_real_output, 'value');                 % to draw
    GA_plot = get(handles.show_GA_output, 'value');                     % the
    least_plot = get(handles.show_least_output, 'value');               % output
    % without
    if (real_plot && ~GA_plot && ~least_plot)                           % doing
        hold off;                                                       % the
        plot(evalin('base', get(handles.out, 'string')), 'k');          % estimation
        title('Output of Real, GA and Least Square estimations models');%
        xlabel('Time');                                                 %
        ylabel('Output');                                               %
    else
        plot_output(handles);                                   % while this is for the other cases
    end
catch
    errordlg('Enter Input and Output vectors as they appear on Workspace', 'No I/O Data Availlable', 'on');
end

% --- Executes on button press in show_GA_output.
function show_GA_output_Callback(hObject, eventdata, handles)
% hObject    handle to show_GA_output (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of show_GA_output
plot_output(handles);

% --- Executes on button press in show_least_output.
function show_least_output_Callback(hObject, eventdata, handles)
% hObject    handle to show_least_output (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of show_least_output
plot_output(handles);

% ----- Plot Real, GA, Least Square estimation outputs -----
function plot_output(handles)
real_plot = get(handles.show_real_output, 'value');
GA_plot = get(handles.show_GA_output, 'value');
least_plot = get(handles.show_least_output, 'value');
try
    if (~real_plot && ~GA_plot && ~least_plot) ,cla(handles.axes1);end
    if (~real_plot && ~GA_plot && least_plot) ,hold off; plot(handles.least_model_output,'b');end
    if (~real_plot && GA_plot && ~least_plot) ,hold off; plot(handles.GA_model_output,'r');end
    if (~real_plot && GA_plot && least_plot) ,hold off; plot(handles.GA_model_output, 'r'); hold on; plot(handles.least_model_output, 'b');end
    if (real_plot && ~GA_plot && ~least_plot) ,hold off; plot(handles.real_output, 'k');end
    if (real_plot && ~GA_plot && least_plot) ,hold off; plot(handles.real_output, 'k'); hold on; plot(handles.least_model_output, 'b');end
    if (real_plot && GA_plot && ~least_plot) ,hold off; plot(handles.real_output,'k'); hold on; plot(handles.GA_model_output, 'r');end
    if (real_plot && GA_plot && least_plot) ,hold off; plot(handles.real_output, 'k'); hold on; plot(handles.GA_model_output, 'r'); plot(handles.least_model_output, 'b');end
catch
    errordlg('No model to plot its output: Enter model orders and I/O data then hit Estimate','No Model','on');
end
title('Output of Real, GA and Least Square estimations models');
xlabel('Time');
ylabel('Output');

% --- Executes on button press in GA.
function GA_Callback(hObject, eventdata, handles)
% hObject    handle to GA (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
GA_parameters = inputdlg({'Error Tolerance', 'Population Size', 'Mutation Rate' , 'No. of iterations'}, 'GA Parameters' , 1,{'0.4', '30', '0.2', '50'});
if ~(strcmp(GA_parameters,''))
    handles.error_tolerance = str2double(GA_parameters{1});
    handles.population_size = str2double(GA_parameters{2});
    handles.mutation_rate = str2double(GA_parameters{3});
    handles.no_of_generations = str2double(GA_parameters{4});
    guidata(hObject, handles);
end


% --------------------------------------------------------------------
function help_menu_Callback(hObject, eventdata, handles)
% hObject    handle to help_menu (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --------------------------------------------------------------------
function Untitled_3_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --------------------------------------------------------------------
function about_Callback(hObject, eventdata, handles)
% hObject    handle to about (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
msgbox('Genetics Identification Toolbox All rights reserved to Wesam ELSHAMY', 'About');

% --------------------------------------------------------------------
function how_to_use_Callback(hObject, eventdata, handles)
% hObject    handle to how_to_use (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
helpdlg('This toolbox identifies an ARX SISO model for a system given its input and output:          First enter the input and output vectors defined in MATLAB Workspace in their respective boxes          Then enter the model orders (Na Nb Nk) in their respective boxes            When you hit GA parameters a new window opens where you can modify the default parameters (error tolerance = 0.4, population size = 100 and muation rate = 0.9)         Then hit Estimate button to estimate A and B parameters             You can toggle the outputs (real, GA generated or the Lease Squares estimate) by toggling the three buttons under the plot', 'How to use');


% --- Executes during object creation, after setting all properties.
function no_of_generations_CreateFcn(hObject, eventdata, handles)
% hObject    handle to no_of_generations (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end





function status_Callback(hObject, eventdata, handles)
% hObject    handle to status (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of status as text27
%        str2double(get(hObject,'String')) returns contents of status as a double


% --- Executes during object creation, after setting all properties.
function status_CreateFcn(hObject, eventdata, handles)
% hObject    handle to status (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end





function GA_error_Callback(hObject, eventdata, handles)
% hObject    handle to GA_error (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of GA_error as text27
%        str2double(get(hObject,'String')) returns contents of GA_error as a double


% --- Executes during object creation, after setting all properties.
function GA_error_CreateFcn(hObject, eventdata, handles)
% hObject    handle to GA_error (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function Least_error_Callback(hObject, eventdata, handles)
% hObject    handle to Least_error (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of Least_error as text
%        str2double(get(hObject,'String')) returns contents of Least_error as a double


% --- Executes during object creation, after setting all properties.
function Least_error_CreateFcn(hObject, eventdata, handles)
% hObject    handle to Least_error (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


⌨️ 快捷键说明

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