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

📄 rbf.asv

📁 线性神经网络
💻 ASV
字号:
function varargout = RBF(varargin)
% RBF M-file for RBF.fig
%      RBF, by itself, creates a new RBF or raises the existing
%      singleton*.
%
%      H = RBF returns the handle to a new RBF or the handle to
%      the existing singleton*.
%
%      RBF('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in RBF.M with the given input arguments.
%
%      RBF('Property','Value',...) creates a new RBF or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before RBF_OpeningFunction gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to RBF_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

% Copyright 2002-2003 The MathWorks, Inc.

% Edit the above text to modify the response to help RBF

% Last Modified by GUIDE v2.5 26-May-2006 21:30:34

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @RBF_OpeningFcn, ...
                   'gui_OutputFcn',  @RBF_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 RBF is made visible.
function RBF_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 RBF (see VARARGIN)

% Choose default command line output for RBF
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes RBF wait for user response (see UIRESUME)
% uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = RBF_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;


% --- Executes on button press in PB_T.
function PB_T_Callback(hObject, eventdata, handles)
% hObject    handle to PB_T (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(findobj('Tag','PB_T'),'userdata');
switch  user_data.chose
    case 1
        P=[-1:0.1:1];
        T=[-0.9602 0.5770,0.0729 0.3771 0.6405 0.6600 0.4609 0.1336...
            -0.2013 -0.4344 -0.5 -0.3930 0.1647 0.0988 0.3072 ...
            0.3960 0.3449 0.1816 -0.0312 -0.2189 -0.3201];
        plot(P,T,'r*');
        
        str1=sprintf('>> P=[-1:0.1:1];\n>> T=[-0.9602 0.5770,0.0729 0.3771 0.6405 0.6600 0.4609 0.1336...');
        str2=sprintf('\n>> -0.2013 -0.4344 -0.5 -0.3930 0.1647 0.0988 0.3072 ...\n>> 0.3960 0.3449 0.1816 -0.0312 -0.2189 -0.3201];');
        str3=sprintf('\n>> plot(P,T,''r*'');');
        str=strcat(str1,str2,str3);
        set(findobj('Tag','edit1'),'String',str);
        
        str='P为输入向量,T为输出向量。';
        set(findobj('Tag','edit2'),'String',str);
        
        user_data.chose=user_data.chose+1;
        user_data.P=P;
        user_data.T=T;
        set(findobj('Tag','PB_T'),'userdata',user_data);
        
        
        set(findobj('Tag','text2'),'String','step1');
        
        set(hObject,'String','Next>>');
    case 2
        T=user_data.T;
        P=user_data.P;
        
        for i=1:5
            net=newrbe(P,T,i);
            y(i,:)=sim(net,P);
        end

        str=sprintf('\n>> for i=1:5\n>>   net=newrbe(P,T,i);\n>>   y(i,:)=sim(net,P);\n>> end');
        set(findobj('Tag','edit1'),'String',str);
        
        str1='代码中我们用RHF网络精确创建函数newrbe,创建了一个准确的RBF网络。由于径向基函数的分布密度可以';
        str2='影响网络的精度,因此,这里将其设定为从1到5,五个精度,观察它们对网络性能的影响';
        str=strcat(str1,str2);
        set(findobj('Tag','edit2'),'String',str);
        
        user_data.chose=user_data.chose+1;
        user_data.net=net;
        user_data.y=y;
        set(findobj('Tag','PB_T'),'userdata',user_data);
                
        set(findobj('Tag','text2'),'String','step2');
    case 3
        T=user_data.T;
        P=user_data.P;
        net=user_data.net;
        y=user_data.y;
      
        hold off
        plot(1:21,y(1,:)-T);
        hold on
        plot(1:21,y(2,:)-T,'+');
        hold on
        plot(1:21,y(3,:)-T,'.');
        hold on
        plot(1:21,y(4,:)-T,'r--');
        hold on
        plot(1:21,y(5,:)-T,'g-');
        hold off
        
        str1=sprintf('>> plot(1:21,y(1,:)-T);\n>> hold on\n>> plot(1:21,y(2,:)-T,''+'');\n>> hold on');
        str2=sprintf('\n>> plot(1:21,y(3,:)-T);\n>> hold on\n>> plot(1:21,y(4,:)-T,''+'');\n>> hold on\n>> plot(1:21,y(5,:)-T,''g-'');');
        str=strcat(str1,str2);
        set(findobj('Tag','edit1'),'String',str);
        
        str='绘制误差曲线';
        set(findobj('Tag','edit2'),'String',str);
        
        user_data.chose=user_data.chose+1;
        set(findobj('Tag','PB_T'),'userdata',user_data);
        
        set(findobj('Tag','text2'),'String','step3');
    case 4        
        set(hObject,'String','Start');
        set(findobj('Tag','edit2'),'String','请按‘开始‘按钮启动演示。若有不明的函数可查看‘帮助’。');
        hold off

        str1='如果要实现同一个功能,径向基的神经元个数可能要比前向BP网络要多,但是径向基网络所';
        str2='需要的训练时间却比BP网络要少。径向基函数网络是由输入层、隐含层和输出层构成的三层前向网络。';
        str=strcat(str1,str2);
        set(findobj('Tag','edit1'),'String',str);
        
        set(findobj('Tag','text2'),'String','step 0');
                
        temp_data.chose=1;
        set(hObject,'userdata',temp_data);
        
end

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


% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit1 (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 PB_T_CreateFcn(hObject, eventdata, handles)
% hObject    handle to PB_T (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.chose=1;
set(findobj('Tag','PB_T'),'userdata',user_data);



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


% --- Executes during object creation, after setting all properties.
function edit2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit2 (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 on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

close;
SysGui;


⌨️ 快捷键说明

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