【预测模型】基于weiner滤波预测matlab源码

一、简介

基于matlab GUI一步线性+weiner滤波预测

二、源代码

``` function varargout = WeinerFilter(varargin) % WEINERFILTER M-file for WeinerFilter.fig % WEINERFILTER, by itself, creates a new WEINERFILTER or raises the existing % singleton. % % H = WEINERFILTER returns the handle to a new WEINERFILTER or the handle to % the existing singleton. % % WEINERFILTER('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in WEINERFILTER.M with the given input arguments. % % WEINERFILTER('Property','Value',...) creates a new WEINERFILTER or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before WeinerFilterOpeningFcn gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to WeinerFilterOpeningFcn 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 WeinerFilter

% Last Modified by GUIDE v2.5 28-May-2021 16:23:34

% Begin initialization code - DO NOT EDIT guiSingleton = 1; guiState = struct('guiName', mfilename, ... 'guiSingleton', guiSingleton, ... 'guiOpeningFcn', @WeinerFilterOpeningFcn, ... 'guiOutputFcn', @WeinerFilterOutputFcn, ... 'guiLayoutFcn', [] , ... 'guiCallback', []); if nargin && ischar(varargin{1}) guiState.gui_Callback = str2func(varargin{1}); end

if nargout [varargout{1:nargout}] = guimainfcn(guiState, varargin{:}); else guimainfcn(guiState, varargin{:}); end % End initialization code - DO NOT EDIT

% --- Executes just before WeinerFilter is made visible. function WeinerFilter_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 WeinerFilter (see VARARGIN)

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

% Update handles structure guidata(hObject, handles); set(handles.listSignal,'string', ... '1-|2-AR过程的信号|3-两个正弦信号叠加+N|4-单一正弦信号|5-SAR_Line'); % UIWAIT makes WeinerFilter wait for user response (see UIRESUME) % uiwait(handles.figure1);

% --- Outputs from this function are returned to the command line. function varargout = WeinerFilter_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 btnWiener. function btnWiener_Callback(hObject, eventdata, handles) % hObject handle to btnWiener (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) %获取数据 pInfo = getappdata(handles.figure1,'mydata'); x=pInfo.pData; s=pInfo.pDataS; M=length(x);

N=str2num(get(handles.edLengthFilter,'string'));
fNoiseM=str2num(get(handles.edNoiseM,'string'));

% 指定输出
axes(handles.axesOut);

%自相关矩阵 %自相关矩阵R
Re=zeros(1,M);
for i=1:N
    for j=1:M
        if j+i-1<=M
            Re(1,i)=x(1,j)*x(1,j+i-1)'/(M-i+1)+Re(1,i);
        end
    end
end
R=zeros(N,N);            
for i=1:N
    for j=i:N
        if(i==j)
            R(i,i)=Re(1,1);
        else
            R(i,j)=Re(1,j-i+1);
            R(j,i)=conj(R(i,j));
        end
    end
end  
%互相关矩阵 r
r=zeros(1,N);             
for i=1:N
    for j=1:M
        if j-i+1>0
            r(1,i)=x(1,j)*s(1,j-i+1)'/(M-i+1)+r(1,i);
        end
    end
end

Wopt=inv(R)*r';           %最优抽头权向量

X=zeros(1,M);             %滤波器输出
for n1=1:M
    if n1<N
            for i=0:n1-1
                X(1,n1)=Wopt(i+1,1)*x(1,n1-i)+X(1,n1);
            end
    else
            for i=0:N-1
                X(1,n1)=Wopt(i+1,1)*x(n1-i)+X(1,n1);
            end
    end
end

% %%去延迟 % for j=1:M % if(j>=M-iDelay-iDelay) % XX(1,j)=0; % else % XX(1,j)=X(1,j+iDelay+iDelay); % end % end

hold off
plot(s,'.-k','linewidth',2);hold on
plot(x,'.-b');
hold on
plot(X,'*-r','linewidth',2);
hold off
legend('原信号','噪声信号','滤波信号')

%% % --- Executes on selection change in listSignal. function listSignal_Callback(hObject, eventdata, handles) % hObject handle to listSignal (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 listSignal contents as cell array % contents{get(hObject,'Value')} returns selected item from listSignal

% --- Executes during object creation, after setting all properties. function listSignal_CreateFcn(hObject, eventdata, handles) % hObject handle to listSignal (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called

% Hint: listbox 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 edLengthSignal_Callback(hObject, eventdata, handles) % hObject handle to edLengthSignal (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 edLengthSignal as text % str2double(get(hObject,'String')) returns contents of edLengthSignal as a double

% --- Executes during object creation, after setting all properties. function edLengthSignal_CreateFcn(hObject, eventdata, handles) % hObject handle to edLengthSignal (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 ```

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184
  • 185
  • 186
  • 187
  • 188
  • 189
  • 190
  • 191
  • 192
  • 193
  • 194

三、运行结果

在这里插入图片描述

四、备注

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Matlab科研辅导帮

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值