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

📄 bpnn.asv

📁 线性神经网络
💻 ASV
📖 第 1 页 / 共 2 页
字号:

% --- Executes on selection change in listbox_train.
function listbox_train_Callback(hObject, eventdata, handles)
% hObject    handle to listbox_train (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns listbox_train contents as cell array
%        contents{get(hObject,'Value')} returns selected item from listbox_train


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

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


% --- Executes on selection change in popupmenu_train.
function popupmenu_train_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenu_train (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns popupmenu_train contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenu_train
chosen=get(hObject,'Value');
%temp_string=get(hObject,'String');
user_data=get(gcf,'UserData');
%user_data.algorithm=temp_string(chosen);
user_data.algorithm=chosen;
set(gcf,'UserData',user_data);


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

% Hint: popupmenu controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
chosen=get(hObject,'Value');
user_data=get(gcf,'UserData');
user_data.algorithm=chosen;
set(gcf,'UserData',user_data);

% --- Executes on button press in pushbutton_CN.
function pushbutton_CN_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton_CN (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
LoadData=get(gcf,'UserData');





% --- Executes on button press in pushbutton_train.
function pushbutton_train_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton_train (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
user_data=get(gcf,'UserData');
P=user_data.datai;
T=user_data.datao;
epochs=user_data.epochs;
goal=user_data.goal;
algorithm=user_data.algorithm;
%set(findobj('Tag','EShow_Out'),'String',algorithm);
switch algorithm
    case 1
        net=newff(minmax(P),[8,1],{'tansig','logsig'},'traingdx');
    case 2
        net=newff(minmax(P),[8,1],{'tansig','logsig'},'trainlm'); 
    case 3
        net=newff(minmax(P),[8,1],{'tansig','logsig'},'traingd');
end
net.trainParam.epochs=epochs;
net.trainParam.goal=goal;
net=train(net,P,T);
y=sim(net,P);
error=y-T;
user_data.err=error;
plot(findobj('Tag','axes2'),P,y,'b*');
set(findobj('Tag','figure1'),'UserData',user_data);

str1=sprintf('>> 网络的建立、训练和仿真过程\n>> et=newff(minmax(P),[8,1],{''tansig'',''logsig''},''traingdx'');');
str2=sprintf('\n>> net.trainParam.epochs=2000\');


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




% --- Executes on button press in pb_EChart.
function pb_EChart_Callback(hObject, eventdata, handles)
% hObject    handle to pb_EChart (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
user_data=get(gcf,'UserData');
error=user_data.err;
x=1:length(error);
hold off;
plot(x,error);




function edit4_Callback(hObject, eventdata, handles)
% hObject    handle to edit4 (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 edit4 as text
%        str2double(get(hObject,'String')) returns contents of edit4 as a double


% --- Executes during object creation, after setting all properties.
function edit4_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit4 (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
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end



function edit_TEpochs_Callback(hObject, eventdata, handles)
% hObject    handle to edit_TEpochs (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 edit_TEpochs as text
%        str2double(get(hObject,'String')) returns contents of edit_TEpochs as a double
user_data=get(gcf,'userdata');
user_data.epochs=str2double(get(hObject,'String'));
set(gcf,'userdata',user_data);

% --- Executes during object creation, after setting all properties.
function edit_TEpochs_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_TEpochs (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
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
user_data=get(gcf,'userdata');
epochs=str2double(get(hObject,'String'));
user_data.epochs=epochs;
set(gcf,'userdata',user_data);

function edit_TGoal_Callback(hObject, eventdata, handles)
% hObject    handle to edit_TGoal (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 edit_TGoal as text
%        str2double(get(hObject,'String')) returns contents of edit_TGoal as a double
user_data=get(gcf,'userdata');
user_data.goal=str2double(get(hObject,'String'));
set(gcf,'userdata',user_data);

% --- Executes during object creation, after setting all properties.
function edit_TGoal_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit_TGoal (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
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
user_data=get(gcf,'userdata');
user_data.goal=str2double(get(hObject,'String'));
set(gcf,'userdata',user_data);



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

% Hint: place code in OpeningFcn to populate axes2
axis([-1 1 -1 1]);

function edit7_Callback(hObject, eventdata, handles)
% hObject    handle to edit7 (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 edit7 as text
%        str2double(get(hObject,'String')) returns contents of edit7 as a double


% --- Executes during object creation, after setting all properties.
function edit7_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit7 (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
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end




% --- Executes during object creation, after setting all properties.
function PCData_CreateFcn(hObject, eventdata, handles)
% hObject    handle to PCData (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called
user_data.state=1;
user_data.length=1;
set(hObject,'userdata',user_data);




% --- If Enable == 'on', executes on mouse press in 5 pixel border.
% --- Otherwise, executes on mouse press in 5 pixel border or over PCData.
function PCData_ButtonDownFcn(hObject, eventdata, handles)
% hObject    handle to PCData (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


⌨️ 快捷键说明

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