function varargout = untitled1(varargin)
% UNTITLED1 M-file for untitled1.fig
% UNTITLED1, by itself, creates a new UNTITLED1 or raises the existing
% singleton*.
%
% H = UNTITLED1 returns the handle to a new UNTITLED1 or the handle to
% the existing singleton*.
%
% UNTITLED1('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in UNTITLED1.M with the given input arguments.
%
% UNTITLED1('Property','Value',...) creates a new UNTITLED1 or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before untitled1_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to untitled1_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 untitled1
% Last Modified by GUIDE v2.5 05-Jun-2017 23:33:18
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @untitled1_OpeningFcn, ...
'gui_OutputFcn', @untitled1_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 untitled1 is made visible.
function untitled1_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 untitled1 (see VARARGIN)
% Choose default command line output for untitled1
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes untitled1 wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = untitled1_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 selection change in day.
function day_Callback(hObject, eventdata, handles)
% hObject handle to day (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 day contents as cell array
% contents{get(hObject,'Value')} returns selected item from day
% --- Executes during object creation, after setting all properties.
function day_CreateFcn(hObject, eventdata, handles)
% hObject handle to day (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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in data.
function data_Callback(hObject, eventdata, handles)
% hObject handle to data (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in wangluo.
function wangluo_Callback(hObject, eventdata, handles)
% hObject handle to wangluo (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
p=[58478 135185 5.46 0.23 16.5 0.21 1005.2 585.44;
67884 152369 5.46 0.27 18.7 0.26 1105.6 575.03;
74462 182563 6.01 0.25 21.6 0.28 1204.6 601.23;
78345 201587 6.12 0.26 25.8 0.29 1316.5 627.89;
82067 225689 6.21 0.26 30.5 0.31 1423.5 676.95;
89403 240568 6.37 0.28 34.9 0.33 1536.2 716.32;
95933 263856 6.38 0.28 39.8 0.36 1632.6 765.24;
104790 285697 6.65 0.30 42.5 0.39 1753.2 812.22;
116694 308765 6.65 0.30 46.7 0.41 1865.5 875.26]';
t=[102569 52365 46251;
124587 60821 56245;
148792 69253 67362;
162568 79856 78165;
186592 91658 90548;
205862 99635 98758;
226598 109862 102564;
245636 120566 111257;
263595 130378 120356]';
a=[1 2 3 5 7 8];
P=p;
for i=1:6
P(a(i),:)=(p(a(i),:)-min(p(a(i),:)))/(max(p(a(i),:))-min(p(a(i),:)));
end
for i=1:3
T(i,:)=(t(i,:)-min(t(i,:)))/(max(t(i,:))-min(t(i,:)));
end
P_train=[P(:,1) P(:,2) P(:,3) P(:,4) P(:,5) P(:,6) P(:,7)];
T_train=[T(:,1) T(:,2) T(:,3) T(:,4) T(:,5) T(:,6) T(:,7)];
P_test=[P(:,8) P(:,9)];
T_test=[T(:,8) T(:,9)];
for i=0.1:0.1:1
net=newgrnn(P_train,T_train,i);
y_out=sim(net,P_train)
y=sim(net,P_test)
end
% --- Executes on button press in yuce.
function yuce_Callback(hObject, eventdata, handles)
% hObject handle to yuce (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
p=[58478 135185 5.46 0.23 16.5 0.21 1005.2 585.44;
67884 152369 5.46 0.27 18.7 0.26 1105.6 575.03;
74462 182563 6.01 0.25 21.6 0.28 1204.6 601.23;
78345 201587 6.12 0.26 25.8 0.29 1316.5 627.89;
82067 225689 6.21 0.26 30.5 0.31 1423.5 676.95;
89403 240568 6.37 0.28 34.9 0.33 1536.2 716.32;
95933 263856 6.38 0.28 39.8 0.36 1632.6 765.24;
104790 285697 6.65 0.30 42.5 0.39 1753.2 812.22;
116694 308765 6.65 0.30 46.7 0.41 1865.5 875.26]';
t=[102569 52365 46251;
124587 60821 56245;
148792 69253 67362;
162568 79856 78165;
186592 91658 90548;
205862 99635 98758;
226598 109862 102564;
245636 120566 111257;
263595 130378 120356]';
a=[1 2 3 5 7 8];
P=p;
for i=1:6
P(a(i),:)=(p(a(i),:)-min(p(a(i),:)))/(max(p(a(i),:))-min(p(a(i),:)));
end
for i=1:3
T(i,:)=(t(i,:)-min(t(i,:)))/(max(t(i,:))-min(t(i,:)));
end
P_train=[P(:,1) P(:,2) P(:,3) P(:,4) P(:,5) P(:,6) P(:,7)];
T_train=[T(:,1) T(:,2) T(:,3) T(:,4) T(:,5) T(:,6) T(:,7)];
P_test=[P(:,8) P(:,9)];
T_test=[T(:,8) T(:,9)];
for i=1:5
net=newgrnn(P_train,T_train,i/10);
temp=sim(net,P_train);
j=3*i;
y_out(j-2,:)=temp(1,:);
y_out(j-1,:)=temp(2,:);
y_out(j,:)=temp(3,:);
temp=sim(net,P_test);
y(j-2,:)=temp(1,:);
y(j-1,:)=temp(2,:);
y(j,:)=temp(3,:);
end
y1=[y_out(1,:);y_out(2,:);y_out(3,:)];
y2=[y_out(4,:);y_out(5,:);y_out(6,:)];
y3=[y_out(7,:);y_out(8,:);y_out(9,:)];
y4=[y_out(10,:);y_out(11,:);y_out(12,:)];
y5=[y_out(13,:);y_out(14,:);y_out(15,:)];
y6=[y(1,:);y(2,:);y(3,:)];
y7=[y(4,:);y(5,:);y(6,:)];
y8=[y(7,:);y(8,:);y(9,:)];
y9=[y(10,:);y(11,:);y(12,:)];
y10=[y(13,:);y(14,:);y(15,:)];
for i=1:7
error1(i)=norm(y1(:,i)-T_train(:,i));
error2(i)=norm(y2(:,i)-T_train(:,i));
error3(i)=norm(y3(:,i)-T_train(:,i));
error4(i)=norm(y4(:,i)-T_train(:,i));
error5(i)=norm(y5(:,i)-T_train(:,i));
end
for i=1:2
error6(i)=norm(y6(:,i)-T_test(:,i));
error7(i)=norm(y7(:,i)-T_test(:,i));
error8(i)=norm(y8(:,i)-T_test(:,i));
error9(i)=norm(y9(:,i)-T_test(:,i));
error10(i)=norm(y10(:,i)-T_test(:,i));
end
axes(handles.axes1);
title('网络的逼近误差');
plot(1:7,error1,'-*');
hold on;
plot(1:7,error2,'-+');
hold on;
plot(1:7,error3,'-h