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

Posted MatlabQQ1575304183

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了预测模型基于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 WeinerFilter_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to WeinerFilter_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 WeinerFilter

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

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @WeinerFilter_OpeningFcn, ...
                   'gui_OutputFcn',  @WeinerFilter_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 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

三、运行结果

在这里插入图片描述

四、备注

以上是关于预测模型基于weiner滤波预测matlab源码的主要内容,如果未能解决你的问题,请参考以下文章

预测模型基于最小二乘法预测数据matlab源码

预测模型基于matlab离散状态空间模型模拟预测控制仿真系统(单输入单输出)含Matlab源码 1537期

预测模型基于matlab粒子群算法预测含Matlab源码 1326期

预测模型基于灰度预测之房价的预测matlab源码

预测模型基于灰度预测之房价的预测matlab源码

预测模型基于 Elm神经网络的电力负荷预测模型matlab源码