📄 fxzxec.m
字号:
function varargout = fxzxec(varargin)
% FXZXEC M-file for fxzxec.fig
% FXZXEC, by itself, creates a new FXZXEC or raises the existing
% singleton*.
%
% H = FXZXEC returns the handle to a new FXZXEC or the handle to
% the existing singleton*.
%
% FXZXEC('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in FXZXEC.M with the given input arguments.
%
% FXZXEC('Property','Value',...) creates a new FXZXEC or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before fxzxec_OpeningFunction gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to fxzxec_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 fxzxec
% Last Modified by GUIDE v2.5 17-Nov-2008 14:23:08
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @fxzxec_OpeningFcn, ...
'gui_OutputFcn', @fxzxec_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 fxzxec is made visible.
function fxzxec_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 fxzxec (see VARARGIN)
% Choose default command line output for fxzxec
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes fxzxec wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = fxzxec_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 x_Callback(hObject, eventdata, handles)
% hObject handle to x (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 x as text
% str2double(get(hObject,'String')) returns contents of x as a double
x=get(hObject,'String');
if isnan(x)
set(hObject, 'String', 0);
errordlg('Input must be a array','Error');
end
handles.zxec.x = x;
guidata(hObject,handles)
% --- Executes during object creation, after setting all properties.
function x_CreateFcn(hObject, eventdata, handles)
% hObject handle to x (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
function y_Callback(hObject, eventdata, handles)
% hObject handle to y (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 y as text
% str2double(get(hObject,'String')) returns contents of y as a double
y=get(hObject,'String');
if isnan(y)
set(hObject, 'String', 0);
errordlg('Input must be a array','Error');
end
handles.zxec.y = y;
guidata(hObject,handles)
% --- Executes during object creation, after setting all properties.
function y_CreateFcn(hObject, eventdata, handles)
% hObject handle to y (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
function w_Callback(hObject, eventdata, handles)
% hObject handle to w (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 w as text
% str2double(get(hObject,'String')) returns contents of w as a double
w=get(hObject,'String');
if isnan(w)
set(hObject, 'String', 0);
errordlg('Input must be a array','Error');
end
handles.zxec.w = w;
guidata(hObject,handles)
% --- Executes during object creation, after setting all properties.
function w_CreateFcn(hObject, eventdata, handles)
% hObject handle to w (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
function n_Callback(hObject, eventdata, handles)
% hObject handle to n (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 n as text
% str2double(get(hObject,'String')) returns contents of n as a double
n=str2double(get(hObject,'String'));
if isnan(n)
set(hObject, 'String', 0);
errordlg('Input must be a number','Error');
end
handles.zxec.n = n;
guidata(hObject,handles)
% --- Executes during object creation, after setting all properties.
function n_CreateFcn(hObject, eventdata, handles)
% hObject handle to n (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
function X_Callback(hObject, eventdata, handles)
% hObject handle to X (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 X as text
% str2double(get(hObject,'String')) returns contents of X as a double
X=get(hObject,'String');
if isnan(X)
set(hObject, 'String', 0);
errordlg('Input must be a array','Error');
end
handles.zxec.X = X;
guidata(hObject,handles)
% --- Executes during object creation, after setting all properties.
function X_CreateFcn(hObject, eventdata, handles)
% hObject handle to X (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 plotBtn.
function plotBtn_Callback(hObject, eventdata, handles)
% hObject handle to plotBtn (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
x=str2num(handles.zxec.x);
y=str2num(handles.zxec.y);
w=str2num(handles.zxec.w);
n=handles.zxec.n;
X=str2num(handles.zxec.X);
A=zeros(n+1,n+1);
B=zeros(n+1,1);
l=size(w);
m=l(2);
for k=1:m
for i=1:(n+1)
for j=1:(n+1)
A(i,j)=x(k)^(i-1)*x(k)^(j-1)*w(k)+A(i,j);
end
end
end
for k=1:m
for i=1:(n+1)
B(i,1)=B(i,1)+y(k)*x(k)^(i-1)*w(k);
end
end
C=inv(A)*B;
a=size(X);
b=a(2);
Y=zeros(b,1);
for k=1:b
for i=1:(n+1)
Y(k)=C(i)*X(k)^(i-1)+Y(k);
end
end
plot(x,y,X,Y,'r+');
% --------------------------------------------------------------------
function open_Callback(hObject, eventdata, handles)
% hObject handle to open (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
file = uigetfile('*.fig');
if ~isequal(file, 0)
open(file);
end
% --------------------------------------------------------------------
function print_Callback(hObject, eventdata, handles)
% hObject handle to print (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
printdlg(handles.figure1)
% --------------------------------------------------------------------
function close_Callback(hObject, eventdata, handles)
% hObject handle to close (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
selection = questdlg(['Close ' get(handles.figure1,'Name') '?'],...
['Close ' get(handles.figure1,'Name') '...'],...
'Yes','No','Yes');
if strcmp(selection,'No')
return;
end
delete(handles.figure1)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -