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

📄 main01.asv

📁 A=alphabet(:,1)+rand(35,1) alphabet是已定义好的字符特征矩阵 A2=sim(netn,A) netn是前面已训练好的神经网络 A2=compet(A2) an
💻 ASV
字号:
function varargout = main01(varargin)
% MAIN01 M-file for main01.fig
%      MAIN01, by itself, creates a new MAIN01 or raises the existing
%      singleton*.
%
%      H = MAIN01 returns the handle to a new MAIN01 or the handle to
%      the existing singleton*.
%
%      MAIN01('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in MAIN01.M with the given input arguments.
%
%      MAIN01('Property','Value',...) creates a new MAIN01 or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before main01_OpeningFunction gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to main01_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 main01

% Last Modified by GUIDE v2.5 02-Jan-2001 14:03:28

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

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

% Update handles structure
guidata(hObject, handles);

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


% --- Outputs from this function are returned to the command line.
function varargout = main01_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 pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
[alphabet,targets]=prprob;
[R,Q] = size(alphabet);
[S2,Q] = size(targets);
S1 = 10;
[R,Q] = size(alphabet);
[S2,Q] = size(targets);
P = alphabet;
net = newff(minmax(P),[S1 S2],{'logsig' 'logsig'},'traingdx');
net.LW{2,1}=net.LW{2,1}*0.01;
net.b{2}=net.b{2}*0.01;
T=targets;
net.performFcn='sse';
net.trainParam.goal=0.1;
net.trainParam.show=20;
net.trainParam.epochs=5000;
net.trainParam.mc=0.95;
[net,tr]=train(net,P,T);
netn=net;
netn. trainParam.goal=0.6;
netn.trainParam.epochs=300;
T=[targets, targets, targets, targets];
for pass=1:10
P=[alphabet, alphabet, ( alphabet+randn(R,Q)*0.1), ( alphabet+randn(R,Q)*0.2)];
[netn,tr]=train(netn,P,T);
end
netn.trainParam.goal=0.1;
netn.trainParam.epochs=500;
netn.trainParam.show=5;
P=alphabet;
T=targets;
[netn,tr]=train(netn,P,T);
save nnet net
save nnetn netn
msgbox('训练完毕,请继续其他操作...','消息提示','help','modal');
set(handles.pushbutton2,'Enable','on');

% --- 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)
load nnet net
load nnetn netn
[alphabet,targets]=prprob;
noise_range=0:.05:.5;
max_test=100;
network1=[];
network2=[];
T=targets;
for  noiselevel=noise_range
errors1=0;
errors2=0;
for  i=1:max_test
P=alphabet+randn(35,26)* noiselevel;
A=sim(net,P);
AA=compet(A);
errors1= errors1+sum(sum(abs(AA-T)))/2;
An=sim(netn,P);
AAn=compet(An);
errors2= errors2+sum(sum(abs(AAn-T)))/2;
end
network1=[network1 errors1/26/100];
network2=[network2 errors2/26/100];
end
plot(noise_range,network1*100,'--',noise_range,network2*100);
title('识别误差');
xlabel('噪声指标');
ylabel('无噪声网络-- 有噪声网络');


% --- Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
[alphabet,targets]=prprob;
k=round(1+25*rand(1));
noiseA=alphabet(:,k)+randn(35,1)*0.2;
plotchar(noiseA);
save noise noiseA
% --- Executes on button press in pushbutton4.
function pushbutton4_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
load nnet net
load nnetn netn
load noise noiseA
[alphabet,targets]=prprob;
A2=sim(net, noiseA);
A2=compet(A2);
answer=find(compet(A2)==1);
plotchar(alphabet(:,answer));




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
str=get(hObject,'String');
save nstr str

% --- 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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


% --- Executes on button press in pushbutton5.
function pushbutton5_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton5 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
try
    load nstr str
    strA=[];
    [a,b]=size(str);
    k=1;
    for i=1:2:b
        strA(k,1)=eval(str(:,i));
        k=k+1;
    end
        plotchar(strA);
catch
    errordlg('数据有问题,请检查!');
end
save noise1 strA

% --- Executes on button press in pushbutton6.
function pushbutton6_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton6 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
set(handles.edit1,'String','');

% --- Executes on button press in pushbutton7.
function pushbutton7_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton7 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
load nnet net
load nnetn netn
load noise1 strA
[alphabet,targets]=prprob;
A3=sim(net, strA);
A3=compet(A3);
answer1=find(compet(A3)==1);
plotchar(alphabet(:,answer1));

% --- Executes on button press in pushbutton8.
function pushbutton8_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton8 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
button=questdlg('是否退出?','退出提示','退出','继续','继续');
if strcmp(button,'退出')
    close(gcf);
end





⌨️ 快捷键说明

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