function varargout = bp_demo(varargin)
% BP_DEMO M-file for bp_demo.fig
% BP_DEMO, by itself, creates a new BP_DEMO or raises the existing
% singleton*.
%
% H = BP_DEMO returns the handle to a new BP_DEMO or the handle to
% the existing singleton*.
%
% BP_DEMO('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in BP_DEMO.M with the given input arguments.
%
% BP_DEMO('Property','Value',...) creates a new BP_DEMO or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before bp_demo_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to bp_demo_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help bp_demo
% Last Modified by GUIDE v2.5 09-Jan-2010 19:18:03
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @bp_demo_OpeningFcn, ...
'gui_OutputFcn', @bp_demo_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before bp_demo is made visible.
function bp_demo_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to bp_demo (see VARARGIN)
% Choose default command line output for bp_demo
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes bp_demo wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = bp_demo_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
function t_sim_Callback(hObject, eventdata, handles)
% hObject handle to t_sim (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 t_sim as text
% str2double(get(hObject,'String')) returns contents of t_sim as a double
% --- Executes during object creation, after setting all properties.
function t_sim_CreateFcn(hObject, eventdata, handles)
% hObject handle to t_sim (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 train_button.
function train_button_Callback(hObject, eventdata, handles)
% hObject handle to train_button (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
warning off
global net P_train T_train N Epochs Show Goal Lr fcn_hidden fcn_output fcn_learn
% default value
N=10;
Epochs=1000;
Show=10;
Goal=1e-3;
Lr=0.01;
fcn_hidden='tansig';
fcn_output='purelin';
fcn_learn='trainlm';
% create neural network
net=newff(minmax(P_train),[N size(T_train,1)],{fcn_hidden,fcn_output},fcn_learn);
net.trainParam.epochs=Epochs;
net.trainParam.show=Show;
net.trainParam.goal=Goal;
net.trainParam.lr=Lr;
net.trainParam.showwindow=0;
[net,tr]=train(net,P_train,T_train);
% show waitbar
perf=tr.perf;
perf_t=abs(perf(2:end)-perf(1))/(perf(1)-perf(end));
h=waitbar(0,'please wait.......');
for i=1:length(perf_t)
waitbar(perf_t(i));
end
close(h);
% --- Executes on button press in sim_button.
function sim_button_Callback(hObject, eventdata, handles)
% hObject handle to sim_button (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global net P_test T_test mint maxt T_sim
% simulation
cla(handles.axes1);
T_sim=sim(net,P_test);
axes(handles.axes1);
plot(1:size(T_test,2),T_test,'b-o');
hold on;
if get(handles.normalize_radiobutton,'value')==1
T_sim=postmnmx(T_sim,mint,maxt);
plot(1:size(T_sim,2),T_sim,'r-*');
legend(handles.axes1,'真实值','仿真值')
title('归一化')
else
plot(1:size(T_sim,2),T_sim,'k-^');
legend(handles.axes1,'真实值','仿真值')
title('未归一化')
end
set(handles.t_sim,'enable','on','string',num2str(T_sim));
grid on;
% --- Executes on button press in save_button.
function save_button_Callback(hObject, eventdata, handles)
% hObject handle to save_button (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global net
[filename,pathname]=uiputfile('*.mat','save data as');
file=strcat(pathname,filename);
save(file,'net');
% --- Executes on button press in close_button.
function close_button_Callback(hObject, eventdata, handles)
% hObject handle to close_button (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
close;
function t_test_Callback(hObject, eventdata, handles)
% hObject handle to t_test (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 t_test as text
% str2double(get(hObject,'String')) returns contents of t_test as a double
global T_test
T_test=str2num(get(hObject,'string'));
% --- Executes during object creation, after setting all properties.
function t_test_CreateFcn(hObject, eventdata, handles)
% hObject handle to t_test (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 p_test_Callback(hObject, eventdata, handles)
% hObject handle to p_test (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 p_test as text
% str2double(get(hObject,'String')) returns contents of p_test as a double
global P_test
P_test=str2num(get(hObject,'string'));
% --- Executes during object creation, after setting all properties.
function p_test_CreateFcn(hObject, eventdata, handles)
% hObject handle to p_test (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
邓凌佳
- 粉丝: 82
- 资源: 1万+
最新资源
- ssm校园快递一站式服务系统+jsp.zip
- ssm校园教务系统+vue.zip
- ssm校园美食交流系统+vue.zip
- 西门子s7 200smart与力士乐VFC3610变频器通讯原创可直接用于生产的程序,程序带注释,并附送触摸屏程序,有接线方式和设置,通讯地址说明等 程序采用轮询,可以后续根据要求适当修改后扩展
- ssm小型企业办公自动化系统的设计和开发+vue.zip
- ssm校园活动管理平台+vue.zip
- ssm小学生课外知识学习网站+vue.zip
- ssm物流管理系统设计与实现+jsp.zip
- ssm线上学习网站+vue.zip
- ssm线上旅行信息管理系统ssm+vue.zip
- ssm网上医院预约挂号系统+jsp.zip
- ssm网上花店设计+vue.zip
- 基于stm32的自动调速风扇(只是资料程序,无实物) 1)使用的芯片为STM32最小系统板来作为中心控制器 (2)驱动电机用L298N芯片驱动直流电机 (3)传感器模块使用热释电人体红外传感模块H
- ssm网上服装销售系统+jsp.zip
- ssm网络游戏公司官方平台设计与实现+jsp.zip
- ssm网络安全宣传网站设计+jsp.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
评论0