function varargout = ch4(varargin)
% CH4 M-file for ch4.fig
% CH4, by itself, creates a new CH4 or raises the existing
% singleton*.
%
% H = CH4 returns the handle to a new CH4 or the handle to
% the existing singleton*.
%
% CH4('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in CH4.M with the given input arguments.
%
% CH4('Property','Value',...) creates a new CH4 or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before ch4_OpeningFunction gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to ch4_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 ch4
% Last Modified by GUIDE v2.5 18-Oct-2007 08:57:05
% Begin initialization code - DO NOT EDIT
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)
% 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
msgbox('No wave exist! Please choose a input type!');
return;
end
%guo ling jian ce
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
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);
% --- Executes on button press in WAVfile.
function WAVfile_Callback(hObject, eventdata, handles)
% hObject handle to WAVfile (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
h=findobj('Tag','filename');
set(h,'enable','on');
h=findobj('Tag','freq');
set(h,'enable','off');
h=findobj('Tag','amp');
set(h,'enable','off');
h=findobj('Tag','phase');
set(h,'enable','off');
set(findobj('Tag','recordtime'),'enable','off');
set(handles.channel,'enable','on');
set(handles.fileopen,'enable','on');
set(handles.gensig,'enable','off');
set(handles.wavetype,'enable','off');
set(handles.add,'enable','off');
set(handles.startrecord,'enable','off');
% --- Executes on button press in soundcard.
function soundcard_Callback(hObject, eventdata, handles)
% hObject handle to soundcard (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
set(findobj('Tag','recordtime'),'enable','on');
h=findobj('Tag','filename');
set(h,'enable','off');
h=findobj('Tag','freq');
set(h,'enable','off');
h=findobj('Tag','amp');
set(h,'enable','off');
h=findobj('Tag','phase');
set(h,'enable','off');
set(handles.channel,'enable','off');
set(handles.fileopen,'enable','off');
set(handles.gensig,'enable','off');
set(handles.wavetype,'enable','off');
set(handles.add,'enable','off');
set(handles.startrecord,'enable','on');
% --- Executes on button press in generator.
function generator_Callback(hObject, eventdata, handles)
% hObject handle to generator (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
h=findobj('Tag','filename');
set(h,'enable','off');
h=findobj('Tag','freq');
set(h,'enable','on');
h=findobj('Tag','amp');
set(h,'enable','on');
h=findobj('Tag','phase');
set(h,'enable','on');
set(findobj('Tag','recordtime'),'enable','off');
set(handles.channel,'enable','off');
set(handles.fileopen,'enable','off');
set(handles.gensig,'enable','on');
set(handles.wavetype,'enable','on');
set(handles.add,'enable','on');
set(handles.startrecord,'enable','off');
function filename_Callback(hObject, ev
声音信号频谱分析仪 MATLAB源码
5星 · 超过95%的资源 需积分: 49 83 浏览量
2010-01-08
15:47:25
上传
评论
收藏 18KB RAR 举报
angel59218
- 粉丝: 7
- 资源: 37
最新资源
- 通道处理过程的模拟通常涉及对通道处理机制的理解与实现.txt
- Flume进阶-自定义拦截器jar包
- Dubins曲线算法讲解和在运动规划中的使用.pdf
- 上市公司-股票性质数据-工具变量(民企、国企、央企)2003-2022年.dta
- 上市公司-股票性质数据-工具变量(民企、国企、央企)2003-2022年.xlsx
- Reeds+Shepp曲线算法讲解和实现.pdf
- 毕业设计基于SpringBoot+MyBatisPlus+MySQL+Vue的外卖配送信息系统源代码+数据库
- 词向量(Word Embeddings)是自然语言处理(NLP)领域的一种重要技术.txt
- Surfer,线性函数
- MyBatis 的动态 SQL 是其核心特性之一.txt
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈