⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 chenguideruslt2.m

📁 数字信号处理的一个课程设计
💻 M
📖 第 1 页 / 共 2 页
字号:
hd(M)=wc/pi;
h1=hd.*rot90(w1);
[mag1,rad]=freqz(h1,1,512);
a1=angle(mag1);

plot(rad,20*log10(abs(mag1)));
title('矩形窗');
xlabel('w');
ylabel('对数幅值(db)');
axis tight;
grid on;
set(gcf,'CurrentAxes',handles.axes1);


% --- 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)
handles.wp=handles.wp*pi;
handles.ws=handles.ws*pi;


p=[1 2 2 4 0.9];
 w=handles.ws-handles.wp;
 wc=(handles.ws+handles.wp)/2+eps;
 if handles.k<13
N=ceil(p(5)*4*pi/w+eps);
 elseif handles.k>=13&handles.k<31
 N=ceil(p(1)*4*pi/w+eps);
elseif handles.k>=31&handles.k<41
    N=ceil(p(2)*4*pi/w+eps);
elseif handles.k>=41&handles.k<57
    N=ceil(p(3)*4*pi/w+eps);
elseif handles.k>=57
    N=ceil(p(4)*4*pi/w+eps);
end
if rem(N,2)==0
    N=N+1;
end
M=(N+1)/2;
w3=hamming(N);
n=1:1:N;
hd=sin(wc*(n-M))./((pi*(n-M)+eps));
hd(M)=wc/pi;
h3=hd.*rot90(w3);

[mag3,rad]=freqz(h3,1,512);
a3=angle(mag3);
plot(rad,20*log10(abs(mag3)));
axis tight;
title('海明窗');
xlabel('w');
ylabel('对数幅值(db)');
grid on;
set(gcf,'CurrentAxes',handles.axes1);

% --- 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)
handles.wp=handles.wp*pi;
handles.ws=handles.ws*pi;


p=[1 2 2 4 0.9];
 w=handles.ws-handles.wp;
 wc=(handles.ws+handles.wp)/2+eps;
if handles.k<13
N=ceil(p(5)*4*pi/w+eps);
elseif handles.k>=13&handles.k<31
 N=ceil(p(1)*4*pi/w+eps);
elseif handles.k>=31&handles.k<41
    N=ceil(p(2)*4*pi/w+eps);
elseif handles.k>=41&handles.k<57
    N=ceil(p(3)*4*pi/w+eps);
elseif handles.k>=57
    N=ceil(p(4)*4*pi/w+eps);
end
if rem(N,2)==0
    N=N+1;
end
M=(N+1)/2;
w2=hanning(N);
n=1:1:N;
hd=sin(wc*(n-M))./((pi*(n-M)+eps));
hd(M)=wc/pi;
w2=hanning(N);
n=1:1:N;
hd=sin(wc*(n-M))./((pi*(n-M)+eps));
hd(M)=wc/pi;
h2=hd.*rot90(w2);
[mag2,rad]=freqz(h2,1,512);
a2=angle(mag2);
plot(rad,20*log10(abs(mag2)));
axis tight
title('汉宁窗');
xlabel('w');
ylabel('对数幅值(db)');
grid on;
set(gcf,'CurrentAxes',handles.axes1);


% --- 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)
handles.wp=handles.wp*pi;
handles.ws=handles.ws*pi;


p=[1 2 2 4 0.9];
 w=handles.ws-handles.wp;
 wc=(handles.ws+handles.wp)/2+eps;
 if handles.k<13
N=ceil(p(5)*4*pi/w+eps);
 elseif handles.k>=13&handles.k<31
 N=ceil(p(1)*4*pi/w+eps);
elseif handles.k>=31&handles.k<41
    N=ceil(p(2)*4*pi/w+eps);
elseif handles.k>=41&handles.k<57
    N=ceil(p(3)*4*pi/w+eps);
elseif handles.k>=57
    N=ceil(p(4)*4*pi/w+eps);
end
if rem(N,2)==0
    N=N+1;
end
M=(N+1)/2;
n=1:1:N;
hd=sin(wc*(n-M))./((pi*(n-M)+eps));
hd(M)=wc/pi;
w4=blackman(N);
n=1:1:N;
hd=sin(wc*(n-M))./((pi*(n-M)+eps));
hd(M)=wc/pi;
h4=hd.*rot90(w4);
[mag4,rad]=freqz(h4,1,512);
a4=angle(mag4);
plot(rad,20*log10(abs(mag4)));
axis tight;
title('布莱克曼窗');
xlabel('w');
ylabel('对数幅值(db)');
grid on;
set(gcf,'CurrentAxes',handles.axes1);


% --- Executes on button press in pushbutton5.
function pushbutton5_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton5 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
handles.wp=handles.wp*pi;
handles.ws=handles.ws*pi;


p=[1 2 2 4 0.9];
 w=handles.ws-handles.wp;
 wc=(handles.ws+handles.wp)/2+eps;
 if handles.k<13
N=ceil(p(5)*4*pi/w+eps);
 elseif handles.k>=13&handles.k<31
 N=ceil(p(1)*4*pi/w+eps);
elseif handles.k>=31&handles.k<41
    N=ceil(p(2)*4*pi/w+eps);
elseif handles.k>=41&handles.k<57
    N=ceil(p(3)*4*pi/w+eps);
elseif handles.k>=57
    N=ceil(p(4)*4*pi/w+eps);
end
if rem(N,2)==0
    N=N+1;
end
M=(N+1)/2;
n=1:1:N;
hd=sin(wc*(n-M))./((pi*(n-M)+eps));
hd(M)=wc/pi;
w5=kaiser(N,handles.BETA);
n=1:1:N;
hd=sin(wc*(n-M))./((pi*(n-M)+eps));
hd(M)=wc/pi;
h5=hd.*rot90(w5);
[mag5,rad]=freqz(h5,1,512);
a5=angle(mag5);

plot(rad,20*log10(abs(mag5)));
title('凯塞窗');
xlabel('w');
ylabel('对数幅值(db)');
axis([0 pi -160 5]);;
grid on;
set(gcf,'CurrentAxes',handles.axes1);



% --- Executes on button press in sure.
function sure_Callback(hObject, eventdata, handles)
% hObject    handle to sure (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

handles.wp=handles.wp*pi;
handles.ws=handles.ws*pi;

p=[1 2 2 4 0.9];
w=handles.ws-handles.wp;
wc=(handles.ws+handles.wp)/2+eps;
if handles.k<13
N1=ceil(p(5)*4*pi/w+eps);
hn=fir1(N1,wc/pi,boxcar(N1+1));
elseif handles.k>=13&handles.k<31
N1=ceil(p(1)*4*pi/w+eps);
hn=fir1(N1,wc/pi,hanning(N1+1))
elseif handles.k>=31&handles.k<41
N1=ceil(p(2)*4*pi/w+eps);
hn=fir1(N1,wc/pi,hamming(N1+1));
elseif handles.k>=41&handles.k<57
N1=ceil(p(3)*4*pi/w+eps);
hn=fir1(N1,wc/pi,blackman(N1+1));
elseif handles.k>=57
N1=ceil(p(4)*4*pi/w+eps);
hn=fir1(N1,wc/pi,kaiser(N1+1));
end
if rem(N1,2)==0
    N1=N1+1;
end


set(handles.X,'string',hn);
set(handles.N, 'String', N1);


% --- Executes on selection change in listbox1.
function listbox1_Callback(hObject, eventdata, handles)
% hObject    handle to listbox1 (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 listbox1 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from listbox1


% --- Executes during object creation, after setting all properties.
function listbox1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to listbox1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: listbox 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


% --- Executes on selection change in X.
function listbox2_Callback(hObject, eventdata, handles)
% hObject    handle to X (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 X contents as cell array
%        contents{get(hObject,'Value')} returns selected item from X


% --- Executes during object creation, after setting all properties.
function listbox2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to X (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: listbox 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


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -