📄 all.m
字号:
function varargout = all(varargin)
% ALL M-file for all.fig
% ALL, by itself, creates a new ALL or raises the existing
% singleton*.
%
% H = ALL returns the handle to a new ALL or the handle to
% the existing singleton*.
%
% ALL('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in ALL.M with the given input arguments.
%
% ALL('Property','Value',...) creates a new ALL or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before all_OpeningFunction gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to all_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_a to modify the response to help all
% Last Modified by GUIDE v2.5 02-Jul-2007 16:05:11
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @all_OpeningFcn, ...
'gui_OutputFcn', @all_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 all is made visible.
function all_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 all (see VARARGIN)
% Choose default command line output for all
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes all wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = all_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 ed_N_Callback(hObject, eventdata, handles)
% hObject handle to ed_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 ed_N as text_a
% str2double(get(hObject,'String')) returns contents of ed_N as a double
% --- Executes during object creation, after setting all properties.
function ed_N_CreateFcn(hObject, eventdata, handles)
% hObject handle to ed_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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function ed_lmd_Callback(hObject, eventdata, handles)
% hObject handle to ed_lmd (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 ed_lmd as text_a
% str2double(get(hObject,'String')) returns contents of ed_lmd as a double
% --- Executes during object creation, after setting all properties.
function ed_lmd_CreateFcn(hObject, eventdata, handles)
% hObject handle to ed_lmd (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 ed_n_Callback(hObject, eventdata, handles)
% hObject handle to ed_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 ed_n as text_a
% str2double(get(hObject,'String')) returns contents of ed_n as a double
% --- Executes during object creation, after setting all properties.
function ed_n_CreateFcn(hObject, eventdata, handles)
% hObject handle to ed_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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in ps_jd.
%问题,纵坐标不统一,
function ps_jd_Callback(hObject, eventdata, handles)
global glb_in glb_out u_m v_m y1 y2 %原始输入输出数据
global glb_lmd n %系统阶数和参数
global N M a b c %参与运算的数据长度
global glb_theta %系统参数
theta=[-0.5 0.7 0 0.2 -0.1]';
switch get(findobj(gcf,'Tag','mod_1'),'Value')
case 1
a1=ZLS(N,n,glb_in,y1);
[b,a2,ef1]=DLS(N,n,glb_in,y1);
[c,a3,ef2]=GLS(N,n,glb_in,y1);
wc1=norm(a1-theta)/norm(theta);
wc2=norm(a2-theta)/norm(theta);
wc3=norm(a3-theta)/norm(theta);
axes(handles.pic_all);
cla;
plot(1,wc1,'*r','MarkerSize',18,'LineWidth',3);
hold on;plot(2,wc2,'*k','MarkerSize',18,'LineWidth',3);
hold on;plot(3,wc3,'*g','MarkerSize',18,'LineWidth',3);hold off;
s=str2mat(...
'三种算法计算模型一的精度',...
' 红色点为最小二乘整批算法',...
' 黑色点为最小二乘递推算法',...
' 绿色点为广义最小二乘算法');
%模型二
case 0
a12=ZLS(N,n,glb_in,y2);
[b2,a22,ef12]=DLS(N,n,glb_in,y2);
[c2,a32,ef22]=GLS(N,n,glb_in,y2);
wc12=norm(a12-theta)/norm(theta);
wc22=norm(a22-theta)/norm(theta);
wc32=norm(a32-theta)/norm(theta);
axes(handles.pic_all);
cla;
plot(1,wc12,'*r','MarkerSize',18,'LineWidth',3);
hold on;plot(2,wc22,'*k','MarkerSize',18,'LineWidth',3);
hold on;plot(3,wc32,'*g','MarkerSize',18,'LineWidth',3);hold off;
s=str2mat(...
'三种算法计算模型二的精度',...
' 红色点为最小二乘整批算法',...
' 黑色点为最小二乘递推算法',...
' 绿色点为广义最小二乘算法');
end
set(findobj(gcf,'Tag','text_sy'),'String',s);
% hObject handle to ps_jd (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 ps_bh.
function ps_bh_Callback(hObject, eventdata, handles)
theta=[-0.5 0.7 0 0.2 -0.1]';
N =5000;
n=2;
Lmd=0.01; %laimuda的值
uo=randn(1,N);
vo=randn(1,N);%噪声
b=[0 1 -0.5];
a=[5 -2.5 3.5];
c=[1 0 0];
y1o=filter(b,a,uo)+Lmd*vo;
y2o=filter(b,a,uo)+filter(c,a,Lmd*vo);
switch get(findobj(gcf,'Tag','rb_zls'),'Value')
case 1
for i=1:500
N=i*10;
u=uo(1,1:N);
y1=y1o(1,1:N);
y2=y2o(1,1:N);
a1=ZLS(N,n,u,y1);
a2=ZLS(N,n,u,y2);
wc11(i)=norm(a1-theta)/norm(theta);
wc12(i)=norm(a2-theta)/norm(theta);
end
axes(handles.pic_all);
cla;
plot(wc11);
hold on;
plot(wc12,'r');
hold off;
s=str2mat(...
'采用整批算法的数据饱和现象',...
'蓝色曲线为模型一',...
'红色曲线为模型一',...
'注:数据点数范围为10-5000',...
' 每隔10点计算一次误差',...
' 纵坐标表示估计结果与真值的误差',...
' 横坐标表示数据点数',...
' 计算中使用的数据是另外生成的',...
' 数据点数与横坐标的对应关系为',...
' 数据点数=x×10');
set(findobj(gcf,'Tag','text_sy'),'String',s);
case 0
if(get(findobj(gcf,'Tag','rb_dls'),'Value')==1)
for i=1:500
N=i*10;
u=uo(1,1:N);
y1=y1o(1,1:N);
y2=y2o(1,1:N);
[b1,a1,ef1]=DLS(N,n,u,y1);
[b2,a2,ef2]=DLS(N,n,u,y2);
wc11(i)=norm(a1-theta)/norm(theta);
wc12(i)=norm(a2-theta)/norm(theta);
end
axes(handles.pic_all);
cla;
plot(wc11);
hold on;
plot(wc12,'r');
hold off;
s=str2mat(...
'采用递推算法的数据饱和现象',...
'蓝色曲线为模型一',...
'红色曲线为模型一',...
'注:数据点数范围为10-5000',...
' 每隔10点计算一次误差',...
' 纵坐标表示估计结果与真值的误差',...
' 横坐标表示数据点数',...
' 计算中使用的数据是另外生成的',...
' 数据点数与横坐标的对应关系为',...
' 数据点数=x×10');
set(findobj(gcf,'Tag','text_sy'),'String',s);
else
for i=1:500
N=i*10;
u=uo(1,1:N);
y1=y1o(1,1:N);
y2=y2o(1,1:N);
[b1,a1,ef1]=GLS(N,n,u,y1);
[b2,a2,ef2]=GLS(N,n,u,y2);
wc11(i)=norm(a1-theta)/norm(theta);
wc12(i)=norm(a2-theta)/norm(theta);
end
axes(handles.pic_all);
cla;
plot(wc11);
hold on;
plot(wc12,'r');
hold off;
s=str2mat(...
'采用广义二乘的数据饱和现象',...
'蓝色曲线为模型一',...
'红色曲线为模型一',...
'注:数据点数范围为10-5000',...
' 每隔10点计算一次误差',...
' 纵坐标表示估计结果与真值的误差',...
' 横坐标表示数据点数',...
' 计算中使用的数据是另外生成的',...
' 数据点数与横坐标的对应关系为',...
' 数据点数=x×10');
set(findobj(gcf,'Tag','text_sy'),'String',s);
end
end
% hObject handle to ps_bh (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 ps_xzb.
function ps_xzb_Callback(hObject, eventdata, handles)
global N n M a b c %参与运算的数据长度
theta=[-0.5 0.7 0 0.2 -0.1]';
u=randn(1,N);
v=randn(1,N);
for i=1:50
lmd=i/100;
switch get(findobj(gcf,'Tag','mod_1'),'Value')
case 1
y=filter(b,a,u)+lmd*v;
s=str2mat(...
'模型一的情况:',...
'红色曲线为最小二乘整批算法',...
'绿色曲线为最小二乘递推算法',...
'蓝色曲线为广义最小二乘算法',...
'注:lamada的范围是0.01-0.5',...
' 数据点数为N/2',...
' 纵坐标表示估计结果与真值的误差',...
' 计算中使用的数据是另外生成的',...
' lamada与横坐标的对应关系为',...
' lamada=x/100');
case 0
y=filter(b,a,u)+filter(c,a,lmd*v);
s=str2mat(...
'模型二的情况:',...
'红色曲线为最小二乘整批算法',...
'绿色曲线为最小二乘递推算法',...
'蓝色曲线为广义最小二乘算法',...
'注:lamada的范围是0.01-0.5',...
' 数据点数为N/2',...
' 纵坐标表示估计结果与真值的误差',...
' 计算中使用的数据是另外生成的',...
' lamada与横坐标的对应关系为',...
' lamada=x/100');
end
a12=ZLS(N,n,u,y);
[b2,a22,ef12]=DLS(N,n,u,y);
[c2,a32,ef22]=GLS(N,n,u,y);
wc12(i)=norm(a12-theta)/norm(theta);
wc22(i)=norm(a22-theta)/norm(theta);
wc32(i)=norm(a32-theta)/norm(theta);
end
wc12
axes(handles.pic_all);
cla;
plot(wc12,'r');
hold on;
plot(wc22,'g');
hold on;
plot(wc32);
hold off;
set(findobj(gcf,'Tag','text_sy'),'String',s,'FontSize',12);
% hObject handle to ps_xzb (see GCBO)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -