📄 delay.asv
字号:
function varargout = delay(varargin)
% DELAY M-file for delay.fig
% DELAY, by itself, creates a new DELAY or raises the existing
% singleton*.
%
% H = DELAY returns the handle to a new DELAY or the handle to
% the existing singleton*.
%
% DELAY('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in DELAY.M with the given input arguments.
%
% DELAY('Property','Value',...) creates a new DELAY or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before delay_OpeningFunction gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to delay_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 delay
% Last Modified by GUIDE v2.5 17-May-2004 19:36:51
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @delay_OpeningFcn, ...
'gui_OutputFcn', @delay_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin & isstr(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 delay is made visible.
function delay_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 delay (see VARARGIN)
% Choose default command line output for delay
handles.output = hObject;
[y,fs,bits]=wavread('Laser');
x=y(:,1);
axes(handles.axes1);
plot(x);
title('Original signal');
N1=2000;
N2=2*N1;
d=[1 zeros(1,N1-1) 0.9 zeros(1,N1-1) 0.8];
n=[1 zeros(1,N2)];
y1=conv(x,d);
axes(handles.axes2);
plot(y1);
title('Echo signal');
y2=filter(n,d,y1);
axes(handles.axes3);
plot(y2);
title('Noecho signal');
axes(handles.axes4);
nn=0:length(d)-1;
h=stem(nn,d);
set(h,'Linewidth',2);
set(h,'MarkerSize',1);
axes(handles.axes5);
xx=[1 zeros(1,20000)];
h2=filter(n,d,xx);
nn=0:length(h2)-1;
h_2=stem(nn,h2);
set(h_2,'Linewidth',2);
set(h_2,'Linewidth',1);
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes delay wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = delay_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 button press in info.function info_Callback(hObject, eventdata, handles)% hObject handle to info (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% --- Executes on button press in radiobutton1.function radiobutton1_Callback(hObject, eventdata, handles)% hObject handle to radiobutton1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hint: get(hObject,'Value') returns toggle state of radiobutton1set(handles.radiobutton1,'value',1);
set(handles.radiobutton2,'value',0);
set(handles.radiobutton3,'value',0);
[y,fs,bits]=wavread('Laser');
x=y(:,1);
sound(x,fs);
% --- Executes on button press in radiobutton2.function radiobutton2_Callback(hObject, eventdata, handles)% hObject handle to radiobutton2 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hint: get(hObject,'Value') returns toggle state of radiobutton2set(handles.radiobutton1,'value',0);
set(handles.radiobutton2,'value',1);set(handles.radiobutton3,'value',0);[y,fs,bits]=wavread('Laser');
x=y(:,1);
N1=2000;
h1=[1 zeros(1,N1-1) 0.9 zeros(1,N1-1) 0.8];
y1=conv(x,h1);
sound(y1,fs);
% --- Executes on button press in radiobutton3.function radiobutton3_Callback(hObject, eventdata, handles)% hObject handle to radiobutton3 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hint: get(hObject,'Value') returns toggle state of radiobutton3set(handles.radiobutton1,'value',0);
set(handles.radiobutton2,'value',0);
set(handles.radiobutton3,'value',1);
[y,fs,bits]=wavread('Laser');
x=y(:,1);
N1=2000;
N2=2*N1;
d=[1 zeros(1,N1-1) 0.9 zeros(1,N1-1) 0.8];
n=[1 zeros(1,N2)];
y1=conv(x,d);
y2=filter(n,d,y1);
sound(y2,fs);
% --- Executes on button press in pushbutton4.function pushbutton4_Callback(hObject, eventdata, handles)% hObject handle to pushbutton4 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)N1=2000;
d=[1 zeros(1,N1-1) 0.9 zeros(1,N1-1) 0.8];
n=[1];
figure
H1=freqz(n,d,1024);
H2=freqz(d,n,1024);
w=(0:1024-1)/1024*pi;
subplot(3,1,1);
plot(w,abs(H1));
xlabel('Digital angular Frequency');
subplot(3,1,2);
plot(w,abs(H2));
subplot(3,1,3);
plot(w,abs(H1).*abs(H2));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -