【物理应用】基于matlab GUI功率谱估计【含Matlab源码 329期】
一、获取代码方式
获取代码方式1:
完整代码已上传我的资源:【物理应用】基于matlab GUI功率谱估计【含Matlab源码 329期】
获取代码方式2:
通过订阅紫极神光博客付费专栏,凭支付凭证,私信博主,可获得此代码。
备注:
订阅紫极神光博客付费专栏,可免费获得1份代码(有效期为订阅日起,三天内有效);
二、功率谱简介
功率谱估计是一种对信号的功率谱密度进行估计的方法,用于表征信号的能量特征随频率的变化关系,是信号处理领域的常用分析方法。具体可以分为三类:
直接法:周期图法(psd)、pwelch
基于滤波器组方法:Capon、Slapain
基于参数化模型的方法:AR、MA、ARMA
主要分为四章介绍功率谱估计,本章对功率谱估计的基本定义即自相关估计及直接法估计进行描述。
1 基本定义
2 面临的问题
一共有两个面临的问题:
因为加窗的问题会产生分辨率变低,频谱泄露的问题(频带主瓣宽->分辨率低,频谱泄露是固定频率周围有抖动,比如30Hz正弦信号在FFT的30Hz附近有明显的波峰旁瓣,分去了主瓣的能量),如下图所示,如果数据长度越趋近无限,则分辨率越好,中间部分越来越窄,泄露越少。
3 改进方法-直接法
本章主要对直接法这种改进方法进行描述
3.1 周期图法
三、部分源代码
function varargout = SsbForm(varargin)
% SSBFORM M-file for SsbForm.fig
% SSBFORM, by itself, creates a new SSBFORM or raises the existing
% singleton*.
%
% H = SSBFORM returns the handle to a new SSBFORM or the handle to
% the existing singleton*.
%
% SSBFORM('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in SSBFORM.M with the given input arguments.
%
% SSBFORM('Property','Value',...) creates a new SSBFORM or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before SsbForm_OpeningFunction gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to SsbForm_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 SsbForm
% Last Modified by GUIDE v2.5 07-Dec-2008 11:26:04
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @SsbForm_OpeningFcn, ...
'gui_OutputFcn', @SsbForm_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 SsbForm is made visible.
function SsbForm_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 SsbForm (see VARARGIN)
% Choose default command line output for SsbForm
bg=imread('P6.bmp');
axes(handles.axes1);
imshow(bg);
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes SsbForm wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = SsbForm_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 selection change in popupmenu1.
function popupmenu1_Callback(hObject, eventdata, handles)
% hObject handle to popupmenu1 (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 popupmenu1 contents as cell array
% contents{get(hObject,'Value')} returns selected item from popupmenu1
% --- Executes during object creation, after setting all properties.
function popupmenu1_CreateFcn(hObject, eventdata, handles)
% hObject handle to popupmenu1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu 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 selection change in popupmenu2.
function popupmenu2_Callback(hObject, eventdata, handles)
% hObject handle to popupmenu2 (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 popupmenu2 contents as cell array
% contents{get(hObject,'Value')} returns selected item from popupmenu2
% --- Executes during object creation, after setting all properties.
function popupmenu2_CreateFcn(hObject, eventdata, handles)
% hObject handle to popupmenu2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu 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 selection change in popupmenu3.
function popupmenu3_Callback(hObject, eventdata, handles)
% hObject handle to popupmenu3 (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 popupmenu3 contents as cell array
% contents{get(hObject,'Value')} returns selected item from popupmenu3
% --- Executes during object creation, after setting all properties.
function popupmenu3_CreateFcn(hObject, eventdata, handles)
% hObject handle to popupmenu3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu 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 pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global BW CW F t ts
t=[-pi:ts:pi];
ts=0.01;
if get(handles.popupmenu1,'value')==1
elseif get(handles.popupmenu1,'value')==2
BW='5*sin(t)'
elseif get(handles.popupmenu1,'value')==3
BW='10*sin(t)'
elseif get(handles.popupmenu1,'value')==4
BW='15*sin(t)'
end
if get(handles.popupmenu3,'value')==1
elseif get(handles.popupmenu3,'value')==2
F=5
elseif get(handles.popupmenu3,'value')==3
F=10
elseif get(handles.popupmenu3,'value')==4
F=15
end
if get(handles.popupmenu2,'value')==1
elseif get(handles.popupmenu2,'value')==2
CW='cos(2*pi*F*t)'
elseif get(handles.popupmenu2,'value')==3
CW='sin(2*pi*F*t)'
end
if get(handles.popupmenu1,'value')==1 | get(handles.popupmenu2,'value')==1|get(handles.popupmenu3,'value')==1
warndlg('Unfilled Parameter !!!')
else
if get(handles.popupmenu1,'value')==2
set(handles.edit1,'string','BW=5*sin(t)');
elseif get(handles.popupmenu1,'value')==3
set(handles.edit1,'string','BW=10*sin(t)');
elseif get(handles.popupmenu1,'value')==4
set(handles.edit1,'string','BW=15*sin(t)');
end
if CW=='sin(2*pi*F*t)'
set(handles.edit2,'string','CW=sin(2*pi*F*t)');
elseif CW=='cos(2*pi*F*t)'
set(handles.edit2,'string','CW=cos(2*pi*F*t)');
end
if F==5
set(handles.edit3,'string','FC=5');
elseif F==10
set(handles.edit3,'string','FC=10')
elseif F==15
set(handles.edit3,'string','FC=15')
end
end
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
close all
SsbForm
% --- Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
close
SysFirstF
function edit1_Callback(hObject, eventdata, handles)
% hObject handle to edit1 (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 edit1 as text
% str2double(get(hObject,'String')) returns contents of edit1 as a double
% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit1 (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
- 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
- 195
- 196
- 197
- 198
- 199
- 200
- 201
- 202
- 203
- 204
- 205
- 206
- 207
- 208
- 209
- 210
- 211
- 212
- 213
- 214
- 215
- 216
- 217
- 218
- 219
- 220
- 221
- 222
- 223
- 224
- 225
- 226
- 227
- 228
- 229
- 230
- 231
- 232
- 233
- 234
- 235
- 236
- 237
- 238
- 239
- 240
- 241
- 242
- 243
- 244
- 245
- 246
- 247
- 248
四、运行结果
五、matlab版本及参考文献
1 matlab版本
2014a
2 参考文献
[1] 门云阁.MATLAB物理计算与可视化[M].清华大学出版社,2013.
文章来源: qq912100926.blog.csdn.net,作者:海神之光,版权归原作者所有,如需转载,请联系作者。
原文链接:qq912100926.blog.csdn.net/article/details/113851483
- 点赞
- 收藏
- 关注作者
评论(0)