function varargout = shiyan5(varargin)
% SHIYAN5 MATLAB code for shiyan5.fig
% SHIYAN5, by itself, creates a new SHIYAN5 or raises the existing
% singleton*.
%
% H = SHIYAN5 returns the handle to a new SHIYAN5 or the handle to
% the existing singleton*.
%
% SHIYAN5('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in SHIYAN5.M with the given input arguments.
%
% SHIYAN5('Property','Value',...) creates a new SHIYAN5 or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before shiyan5_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to shiyan5_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
% Edit the above text to modify the response to help shiyan5
% Last Modified by GUIDE v2.5 15-Jul-2020 20:58:14
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @shiyan5_OpeningFcn, ...
'gui_OutputFcn', @shiyan5_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 shiyan5 is made visible.
function shiyan5_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 shiyan5 (see VARARGIN)
% Choose default command line output for shiyan5
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes shiyan5 wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = shiyan5_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 xinhao.
function xinhao_Callback(hObject, eventdata, handles)
% hObject handle to xinhao (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns xinhao contents as cell array
% contents{get(hObject,'Value')} returns selected item from xinhao
% --- Executes during object creation, after setting all properties.
function xinhao_CreateFcn(hObject, eventdata, handles)
% hObject handle to xinhao (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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function [X,freq]=positiveFFT(x,Fs) %获得单边正向频域波形
N=length(x); %get the number of points
k=0:N-1; %create a vector from 0 to N-1
T=N/Fs; %get the frequency interval
freq=k/T; %create the frequency range
X=fft(x)/N; % normalize the data
%only want the first half of the FFT, since it is redundant
cutOff = ceil(N/2);
%take only the first half of the spectrum
X = X(1:cutOff);
freq = freq(1:cutOff);
% --- Executes on button press in huitu.
function huitu_Callback(hObject, eventdata, handles)
% hObject handle to huitu (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
val1 = get(handles.xinhao,'value');
handles.Xmin = get(handles.edit3,'String'); %获取坐标区间
handles.Xmax = get(handles.edit4,'String');
handles.Xmin = str2num(handles.Xmin);
handles.Xmax = str2num(handles.Xmax);
handles.x = handles.Xmin:0.5:handles.Xmax;
switch val1
case 1
handles.y = sin(handles.x); %产生正弦波
case 2
handles.y = square(handles.x); %%产生周期为2π,幅值为±1的方波
case 3
handles.y = sawtooth(handles.x,1); %%width=0.5,产生标准对称三角波;
end
axes(handles.axes1);
plot(handles.x,handles.y);
handles.y;fs=100;
n=length(handles.y);
T = 1/fs;%采样间隔
t = (0:n-1)*T;%时间轴
f = (0:n-1)/n*fs;%频率轴
%快速傅里叶变换
handles.yt=fft(handles.y,n)*T;
handles.ytt=abs(handles.yt);
axes(handles.axes2);
plot(f(1:(n-1)/2),handles.ytt(1:(n-1)/2));
grid on;
% fd = (handles.y);
%[YfreqDomain,frequencyRange] = positiveFFT(handles.y,100);
%axes(handles.axes2);
%stem(frequencyRange,abs(YfreqDomain));
%grid
%axis([0,20,0,1])
guidata(hObject,handles) %保存handles.y的结构体,使得handles.y在别的函数中也能用到
% --- Executes on button press in luyin.
function luyin_Callback(hObject, eventdata, handles)
% hObject handle to luyin (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[handles.y,fs]=audioread('test.wav');%声音读取
handles.y = handles.y(:,1); %双通道变单通道
n=length(handles.y);
T = 1/fs;%采样间隔
t = (0:n-1)*T;%时间轴
f = (0:n-1)/n*fs;%频率轴
audio_fft=fft(handles.y,n)*T; %快速傅里叶变换
handles.yf=abs(audio_fft);
axes(handles.axes1);
plot(t,handles.y);
axes(handles.axes2);
plot(f(1:(n-1)/2),handles.yf(1:(n-1)/2));
grid on;
val12=get(handles.zaoshengqdu,'value');%给语音添加指定信噪比的噪声
switch val12
case 1
[handles.yn,~] = noisegen(handles.y,20);
case 2
[handles.yn,~] = noisegen(handles.y,10); %加入信噪比为10dB的高斯白噪声
case 3
[handles.yn,~] = noisegen(handles.y,5);
end
axes(handles.axes3);
plot(handles.yn); %绘图
%msgbox(num2str(snr), '信噪比');
guidata(hObject,handles) %保存handles.y的结构体,使得handles.y在别的函数中也能用到
function zsjz_Callback(hObject, eventdata, handles)
% hObject handle to zsjz (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 zsjz as text
% str2double(get(hObject,'String')) returns contents of zsjz as a double
% --- Executes during object creation, after setting all properties.
function zsjz_CreateFcn(hObject, eventdata, handles)
% hObject handle to zsjz (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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function zsfc_Callback(hObject, eventdata, handles)
% hObject handle to zsfc (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 zsfc as text
% str2double(get(hObject,'String')) returns contents of zsfc as a double
% --- Executes during object creation, after setting all prop
Dyingalive
- 粉丝: 100
- 资源: 4803
最新资源
- Windows检查电池健康度的批处理脚本实现
- 用HTML5和JavaScript实现动态过年鞭炮场景
- 快速排序在Go中的高效实现与应用
- 对象检测23-YOLO(v5至v11)、COCO、CreateML、Paligemma、TFRecord、VOC数据集合集.rar
- 云原生-k8s知识学习-CKA考前培训
- Python实现HTML压缩功能
- 完结26章Java主流分布式解决方案多场景设计与实战
- ECSHOP模板堂最新2017仿E宠物模板 整合ECTouch微分销商城
- Pear Admin 是 一 款 开 箱 即 用 的 前 端 开 发 模 板,提供便捷快速的开发方式,延续 Admin 的设计规范
- 51单片机仿真摇号抽奖机源程序12864液晶显示仿真+程序
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
- 1
- 2
前往页