编程语言
首页 > 编程语言> > 【物理应用】基于matlab的功率谱估计【含Matlab源码 329期】

【物理应用】基于matlab的功率谱估计【含Matlab源码 329期】

作者:互联网

一、简介

功率谱估计是一种对信号的功率谱密度进行估计的方法,用于表征信号的能量特征随频率的变化关系,是信号处理领域的常用分析方法。具体可以分为三类:

直接法:周期图法(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

三、运行结果

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

四、备注

完整代码或者代写添加QQ 1564658423
往期回顾>>>>>>
【物理应用】基于matlab杨氏双缝干涉实验【含Matlab源码 001期】
【物理应用】基于matlab井筒多相流【含Matlab源码 055期】
【物理应用】基于matlab 二维对流扩散温度场【含Matlab源码 056期】
【物理应用】基于matlab内弹道【含Matlab源码 057期】
【物理应用】基于matlab两个光纤光栅的新光子微波发生器的仿真分析【含Matlab源码 058期】
【物理应用】基于matlab计算油气井井底压力【含Matlab源码 059期】
【物理应用】基于matlab光流场【含Matlab源码 060期】
【物理应用】基于matlab 带电粒子在放射状电场和均匀磁场下的混沌运动模拟【含Matlab源码 061期】
【物理应用】基于matlab异构交通流【含Matlab源码 062期】
【物理应用】基于matlab模拟斜抛运动含GUI界面【含Matlab源码 063期】
【物理应用】基于matlab计算晶体结构的x射线衍射图谱【含Matlab源码 064期】
【物理应用】基于matlab衍射光栅教学版【含Matlab源码 065期】
【物理应用】基于matlab电荷电场线和电势【含Matlab源码 066期】
【物理应用】基于matlab速度场找到漩涡【含Matlab源码 067期】
【物理应用】基于matlab车道检测仿真【含Matlab源码 068期】
【物理应用】基于matalb GUI界面的电偶极子【含Matlab源码 069期】
【物理应用】基于matlab车载自组织网络中路边性能及防碰撞算法研究【含Matlab源码 263期】
【物理应用】基于matlab Q学习的无线体域网路由方法【含Matlab源码 264期】
【物理应用】基于matlab GUI家庭室内温湿度控制【含Matlab源码 326期】
【电路仿真】基于simulink三相相控变流器的设计【含Matlab源码 327期】
【物理应用】基于matlab的导线网坐标计算【含Matlab源码 328期】

标签:see,get,谱估计,handles,hObject,源码,eventdata,329
来源: https://blog.csdn.net/TIQCmatlab/article/details/113851483