失眠网,内容丰富有趣,生活中的好帮手!
失眠网 > 【物理应用】基于matlab GUI功率谱估计【含Matlab源码 329期】

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

时间:2023-01-01 01:01:08

相关推荐

【物理应用】基于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- The MathWorks, Inc.% Edit the above text to modify the response to help SsbForm% Last Modified by GUIDE v2.5 07-Dec- 11:26:04% Begin initialization code - DO NOT EDITgui_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});endif nargout[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});elsegui_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 SsbFormbg=imread('P6.bmp');axes(handles.axes1);imshow(bg);handles.output = hObject;% Update handles structureguidata(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 structurevarargout{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 ispcset(hObject,'BackgroundColor','white');elseset(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 ispcset(hObject,'BackgroundColor','white');elseset(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 ispcset(hObject,'BackgroundColor','white');elseset(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 tst=[-pi:ts:pi];ts=0.01;if get(handles.popupmenu1,'value')==1elseif get(handles.popupmenu1,'value')==2BW='5*sin(t)'elseif get(handles.popupmenu1,'value')==3BW='10*sin(t)'elseif get(handles.popupmenu1,'value')==4BW='15*sin(t)'endif get(handles.popupmenu3,'value')==1elseif get(handles.popupmenu3,'value')==2F=5elseif get(handles.popupmenu3,'value')==3F=10elseif get(handles.popupmenu3,'value')==4F=15endif get(handles.popupmenu2,'value')==1elseif get(handles.popupmenu2,'value')==2CW='cos(2*pi*F*t)'elseif get(handles.popupmenu2,'value')==3CW='sin(2*pi*F*t)'endif get(handles.popupmenu1,'value')==1 | get(handles.popupmenu2,'value')==1|get(handles.popupmenu3,'value')==1warndlg('Unfilled Parameter !!!')elseif get(handles.popupmenu1,'value')==2set(handles.edit1,'string','BW=5*sin(t)');elseif get(handles.popupmenu1,'value')==3set(handles.edit1,'string','BW=10*sin(t)');elseif get(handles.popupmenu1,'value')==4set(handles.edit1,'string','BW=15*sin(t)');endifCW=='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)');endifF==5set(handles.edit3,'string','FC=5');elseif F==10set(handles.edit3,'string','FC=10')elseif F==15set(handles.edit3,'string','FC=15')endend% --- 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 allSsbForm% --- 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)closeSysFirstFfunction 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 ispcset(hObject,'BackgroundColor','white');elseset(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));end

四、运行结果

五、matlab版本及参考文献

1 matlab版本

a

2 参考文献

[1] 门云阁.MATLAB物理计算与可视化[M].清华大学出版社,.

如果觉得《【物理应用】基于matlab GUI功率谱估计【含Matlab源码 329期】》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。