【数字信号处理】基于matlab GUI频谱分析仪【含Matlab源码 932期】
【摘要】
一、数字信号处理系统简介
理论知识参考文献:基于GUI的《数字信号处理》教学演示系统的设计 基于Matlab GUI界面的数字信号处理辅助教学系统 基于MATLAB的数字信号处理实验平台
二、部分源代...
一、数字信号处理系统简介
理论知识参考文献:基于GUI的《数字信号处理》教学演示系统的设计
基于Matlab GUI界面的数字信号处理辅助教学系统
基于MATLAB的数字信号处理实验平台
二、部分源代码
unction varargout = ch4(varargin)
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @ch4_OpeningFcn, ...
'gui_OutputFcn', @ch4_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 ch4 is made visible.
function ch4_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 ch4 (see VARARGIN)
% Choose default command line output for ch4
handles.inputtype=0;
xlabel(handles.plot1,'freqency(Hz)');
xlabel(handles.plot2,'freqency(Hz)');
xlabel(handles.plot3,'freqency(Hz)');
xlabel(handles.plot4,'freqency(Hz)');
xlabel(handles.plot5,'freqency(Hz)');
ylabel(handles.plot1,'amplitude');
ylabel(handles.plot2,'phase(rad)');
ylabel(handles.plot3,'real');
ylabel(handles.plot4,'Imaginary');
ylabel(handles.plot5,'power');
handles.output = hObject;
% Update handles structure
guidata(hObject, handles); %更新数据
% UIWAIT makes ch4 wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = ch4_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 during object creation, after setting all properties.
function figure1_CreateFcn(hObject, eventdata, handles)
% hObject handle to figure1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% --- Executes on button press in timeanalyse.
function timeanalyse_Callback(hObject, eventdata, handles) %时域分析Callback
% hObject handle to timeanalyse (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
Fs=str2double(get(findobj('Tag','samplerate'),'String')); %获得界面采样频率数值
N=str2double(get(findobj('Tag','samplenum'),'String')); %获得界面采样点数数值
if handles.inputtype==0 %handles.inputtype记录输入方式 0(默认)为当前无输入;1为声卡录音方式;2为打开文件方式;3为信号生成方式
msgbox('No wave exist! Please choose a input type!');
return;
end
%过 零 监 测
n=1;
ymax=max([handles.y(1) handles.y(2)]);
ymin=min([handles.y(1) handles.y(2)]);
from=str2double(get(handles.pointfrom,'String'));
to=str2double(get(handles.pointto,'String'));
if from<1 | to-from<5; %计算区间过小判定
msgbox('Error range!');
return;
end
for i=from+2:to-1;
if handles.y(i-1)<0 & handles.y(i-2)<0 & handles.y(i)>=0 & handles.y(i+1)>0
if handles.y(i)==0 %若y(i)为0,直接得到零点序号
ti(n)=i;
else
ti(n)=i-handles.y(i)/(handles.y(i)-handles.y(i-1)); %线性内插得到零点序号
% x1=i-1;
% y1=handles.y(i-1);
% x2=i;
% y2=handles.y(i);
% a=handles.y(i)-handles.y(i-1);
% b=a*x1-y1;
% ti(n)=b/a;
end
amp(n)=(ymax-ymin)/2;
ymax=0;
ymin=0;
n=n+1;
else
if ymax<handles.y(i)
ymax=handles.y(i);
end
if ymin>handles.y(i)
ymin=handles.y(i);
end
end
end
n=n-1;
%freqence and periodicity
for i=1:n-1
T(i)=ti(i+1)-ti(i);
end
freq=Fs/mean(T);
set(handles.outt,'String',1/freq); %返回信号周期估计
set(handles.outfreq,'String',num2str(freq)); %返回信号频率估计
%amplitude
set(handles.outamp,'String',num2str(mean(amp(2:n-1)))); %返回信号幅值估计
%phase
phase=2*pi*(1-(ti(1:n-1)-1)./T+floor((ti(1:n-1)-1)./T));
set(handles.outphase,'String',num2str(mean(phase))); %返回信号相位估计
%peak
set(handles.outpeak,'String',(max(handles.y(from:to))-min(handles.y(from:to)))/2); %返回信号峰值估计
%mean
set(handles.outmean,'String',mean(handles.y(from:to))); %返回信号均值估计
%meansquare
set(handles.outmeansquare,'String',mean(handles.y(from:to).^2)); %返回信号均方差估计
%s
set(handles.outs,'String',(std(handles.y(from:to)))^2); %返回信号方差估计
function filename_Callback(hObject, eventdata, handles)
% hObject handle to filename (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 filename as text
% str2double(get(hObject,'String')) returns contents of filename as a double
% --- Executes during object creation, after setting all properties.
function filename_CreateFcn(hObject, eventdata, handles)
% hObject handle to filename (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
function freq_Callback(hObject, eventdata, handles)
% hObject handle to freq (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 freq as text
% str2double(get(hObject,'String')) returns contents of freq as a double
% --- Executes during object creation, after setting all properties.
function freq_CreateFcn(hObject, eventdata, handles)
% hObject handle to freq (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
三、运行结果
四、matlab版本及参考文献
1 matlab版本
2014a
2 参考文献
[1] 沈再阳.精通MATLAB信号处理[M].清华大学出版社,2015.
[2]高宝建,彭进业,王琳,潘建寿.信号与系统——使用MATLAB分析与实现[M].清华大学出版社,2020.
[3]王文光,魏少明,任欣.信号处理与系统分析的MATLAB实现[M].电子工业出版社,2018.
[4]高彦彦,张晶,李莉,贾英茜.基于GUI的《数字信号处理》教学演示系统的设计[J].教育教学论坛. 2019,(48)
[5]李俊,张淑玲,帅晶.基于Matlab GUI界面的数字信号处理辅助教学系统[J].信息通信. 2020,(08)
[6]朱御康.基于MATLAB的数字信号处理实验平台[J].通信电源技术. 2021,38(03)
文章来源: qq912100926.blog.csdn.net,作者:海神之光,版权归原作者所有,如需转载,请联系作者。
原文链接:qq912100926.blog.csdn.net/article/details/117253874
【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)