📄 approximation.m
字号:
function varargout = ExactInterpolaton(varargin)
% EXACTINTERPOLATON M-file for ExactInterpolaton.fig
% EXACTINTERPOLATON, by itself, creates a new EXACTINTERPOLATON or raises the existing
% singleton*.
%
% H = EXACTINTERPOLATON returns the handle to a new EXACTINTERPOLATON or the handle to
% the existing singleton*.
%
% EXACTINTERPOLATON('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in EXACTINTERPOLATON.M with the given input arguments.
%
% EXACTINTERPOLATON('Property','Value',...) creates a new EXACTINTERPOLATON or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before ExactInterpolaton_OpeningFunction gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to ExactInterpolaton_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 ExactInterpolaton
% Last Modified by GUIDE v2.5 25-Jan-2006 22:57:54
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @ExactInterpolaton_OpeningFcn, ...
'gui_OutputFcn', @ExactInterpolaton_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 ExactInterpolaton is made visible.
function ExactInterpolaton_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 ExactInterpolaton (see VARARGIN)
% Choose default command line output for ExactInterpolaton
handles.output = hObject;
handles.user_selection = 1;
handles.interval = 0.1;
handles.stop = 0;
handles.kfold=1;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes ExactInterpolaton wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = ExactInterpolaton_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 test_edit_Callback(hObject, eventdata, handles)
% hObject handle to test_edit (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 test_edit as text
% str2double(get(hObject,'String')) returns contents of test_edit as a double
% --- Executes during object creation, after setting all properties.
function test_edit_CreateFcn(hObject, eventdata, handles)
% hObject handle to test_edit (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 learn_edit_Callback(hObject, eventdata, handles)
% hObject handle to learn_edit (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 learn_edit as text
% str2double(get(hObject,'String')) returns contents of learn_edit as a double
% --- Executes during object creation, after setting all properties.
function learn_edit_CreateFcn(hObject, eventdata, handles)
% hObject handle to learn_edit (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 valid_edit_Callback(hObject, eventdata, handles)
% hObject handle to valid_edit (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 valid_edit as text
% str2double(get(hObject,'String')) returns contents of valid_edit as a double
% --- Executes during object creation, after setting all properties.
% function valid_edit_CreateFcn(hObject, eventdata, handles)
% hObject handle to valid_edit (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 spread_edit_Callback(hObject, eventdata, handles)
% hObject handle to spread_edit (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 spread_edit as text
% str2double(get(hObject,'String')) returns contents of spread_edit as a double
val = str2double(get(hObject,'String'));
if isnumeric(val) & ...
val >= get(handles.spread_slider,'Min') & ...
val <= get(handles.spread_slider,'Max')
set(handles.spread_slider,'Value',val);
else
% Increment the error count, and display it
%handles.number_errors = handles.number_errors+1;
errordlg('Invalid value, the value must between 0 and 3.4 ','Input Error');
set(hObject,'string','0.3');
set(handles.spread_slider,'Value',0.3);
guidata(hObject,handles); % store the changes
end
guidata(hObject,handles);
% --- Executes during object creation, after setting all properties.
function spread_edit_CreateFcn(hObject, eventdata, handles)
% hObject handle to spread_edit (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 slider movement.
function spread_slider_Callback(hObject, eventdata, handles)
% hObject handle to spread_slider (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,'Value') returns position of slider
% get(hObject,'Min') and get(hObject,'Max') to determine range of slider
format short;
set(handles.spread_edit,'String',...
num2str(get(hObject,'Value')));
% --- Executes during object creation, after setting all properties.
function spread_slider_CreateFcn(hObject, eventdata, handles)
% hObject handle to spread_slider (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor',[.9 .9 .9]);
end
set(hObject,'Value',0.3);
% --- Executes on button press in train_pushbutton.
function train_pushbutton_Callback(hObject, eventdata, handles)
% hObject handle to train_pushbutton (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
set(handles.timer_text,'string','0');
handles.stop=0;
timer1 = timer('StartDelay',1,'Period', 1, 'ExecutionMode','fixedDelay');
timer1.timerFcn = {@timer1_callback_fcn,handles,hObject};
start(timer1);
guidata(hObject, handles);
[error,u,w]=train(handles);
%mesh the original fcn
interval = handles.interval;
axes(handles.axes5);
[x1, x2]=meshgrid(-1.5:interval:1.5);
F = 20+x1.^2-10*cos(2*pi*x1)+x2.^2-10*cos(2*pi*x2);
mesh(x1,x2,F);
%mesh the get best net
%working one
[i, j]=meshgrid(-1.5:interval:1.5);
row =size(i);
x=i(:);
x=x';
y=j(:);
y=y';
size(x)
size(y)
size(u)
size(w)
v=simlinear([x;y],u,w);
size(v)
v=reshape(v,row);
axes(handles.axes13);
mesh(j,i,v);
% set(handles.axes13,'zlim',[-1,1]);
%end of workding one
% %testing one
% x=1;
% for i=-1.5:0.1:1.5
% j=-1.5:0.1:1.5;
% i1 = ones(1,31)*i;
% v(x,:)=sim(net,[i1;j]);
% x=x+1;
% end
% [i, j]=meshgrid(-1.5:interval:1.5);
% axes(handles.axes13);
% axis([-2 2 -2 2 0 60]);
% mesh(j,i,v);
% %end of testing
%mesh the error surface
axes(handles.axes14);
set(handles.axes14,'zlim',[0,60]);
er = F-v;
mesh(j,i,er);
set(handles.axes14,'zlim',[0,60]);
%plot the error bar
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -