📄 lowpass.m
字号:
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
function Hr_rp2_Callback(hObject, eventdata, handles)
% hObject handle to Hr_rp2 (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 Hr_rp2 as text
% str2double(get(hObject,'String')) returns contents of Hr_rp2 as a double
% --- Executes during object creation, after setting all properties.
function Hr_rs1_CreateFcn(hObject, eventdata, handles)
% hObject handle to Hr_rs1 (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 Hr_rs1_Callback(hObject, eventdata, handles)
% hObject handle to Hr_rs1 (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 Hr_rs1 as text
% str2double(get(hObject,'String')) returns contents of Hr_rs1 as a double
% --- Executes during object creation, after setting all properties.
function popupmenu2_CreateFcn(hObject, eventdata, handles)
% hObject handle to popupmenu2 (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
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
set(hObject, 'String', { 'Butterworth', 'Chebyshev Type1', 'Chebyshev Type2','Ellipic'});
% --- Executes on selection change in popupmenu2.
function popupmenu2_Callback(hObject, eventdata, handles)
% hObject handle to popupmenu2 (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 popupmenu2 contents as cell array
% contents{get(hObject,'Value')} returns selected item from popupmenu2
% --- Executes during object creation, after setting all properties.
function popupmenu3_CreateFcn(hObject, eventdata, handles)
% hObject handle to popupmenu3 (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
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
set(hObject, 'String', { 'Hamming', 'Hann', 'Kaiser','Triangular','Blackman','Gaussian','Chebyshev'});
% --- Executes on selection change in popupmenu3.
function popupmenu3_Callback(hObject, eventdata, handles)
% hObject handle to popupmenu3 (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 popupmenu3 contents as cell array
% contents{get(hObject,'Value')} returns selected item from popupmenu3
% --- Executes on button press in radio_sporder.
function radio_sporder_Callback(hObject, eventdata, handles)
% hObject handle to radio_sporder (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
set(handles.radio_sporder, 'Value', 1);
set(handles.radio_Minorder, 'Value', 0);
% Hint: get(hObject,'Value') returns toggle state of radio_sporder
% --- Executes on button press in Hr_radio16.
function Hr_radio16_Callback(hObject, eventdata, handles)
% hObject handle to Hr_radio16 (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 Hr_radio16
% --- Executes during object creation, after setting all properties.
function Ho_order_CreateFcn(hObject, eventdata, handles)
% hObject handle to Ho_order (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 Ho_order_Callback(hObject, eventdata, handles)
% hObject handle to Ho_order (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 Ho_order as text
% str2double(get(hObject,'String')) returns contents of Ho_order as a double
% --- Executes during object creation, after setting all properties.
function Hr_rstop1_CreateFcn(hObject, eventdata, handles)
% hObject handle to Hr_rstop1 (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 Hr_rstop1_Callback(hObject, eventdata, handles)
% hObject handle to Hr_rstop1 (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 Hr_rstop1 as text
% str2double(get(hObject,'String')) returns contents of Hr_rstop1 as a double
% --- Executes during object creation, after setting all properties.
function Hr_rpass_CreateFcn(hObject, eventdata, handles)
% hObject handle to Hr_rpass (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 Hr_rpass_Callback(hObject, eventdata, handles)
% hObject handle to Hr_rpass (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 Hr_rpass as text
% str2double(get(hObject,'String')) returns contents of Hr_rpass as a double
% --- Executes during object creation, after setting all properties.
function Hr_rstop2_CreateFcn(hObject, eventdata, handles)
% hObject handle to Hr_rstop2 (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 Hr_rstop2_Callback(hObject, eventdata, handles)
% hObject handle to Hr_rstop2 (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 Hr_rstop2 as text
% str2double(get(hObject,'String')) returns contents of Hr_rstop2 as a double
% --- Executes on button press in radio_iir.
function radio_iir_Callback(hObject, eventdata, handles)
% hObject handle to radio_iir (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 radio_iir
set(handles.radio_iir, 'Value', 1);
set(handles.radio_fir, 'Value', 0);
% --- Executes on button press in radio_fir.
function radio_fir_Callback(hObject, eventdata, handles)
% hObject handle to radio_fir (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 radio_fir
set(handles.radio_iir, 'Value', 0);
set(handles.radio_fir, 'Value', 1);
% --- Executes on button press in Hc_close.
function Hc_close_Callback(hObject, eventdata, handles)
% hObject handle to Hc_close (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 radio_Minorder.
function radio_Minorder_Callback(hObject, eventdata, handles)
% hObject handle to radio_Minorder (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
set(handles.radio_sporder, 'Value', 0);
set(handles.radio_Minorder, 'Value', 1);
% Hint: get(hObject,'Value') returns toggle state of radio_Minorder
% --- Executes on button press in pushbutton_open.
function pushbutton_open_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton_open (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[fname,pname]=uigetfile('*.wav');
[before,FSs,bits]=wavread(fname);
% set(handles.Ho_order, 'String', fname);
handles.metricdata.before = before;
guidata(hObject,handles);
handles.metricdata.FSs = FSs;
guidata(hObject,handles)
handles.metricdata.bits = bits;
guidata(hObject,handles)
% set(handles.fs, 'Value', FSs);
% --- Executes on button press in pushbutton_sound.
function pushbutton_sound_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton_sound (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% set(handles.Hf_fs, 'String',FSs);
if get(handles.radio_Minorder,'Value')==1
sound(handles.metricdata.before,handles.metricdata.FSs,handles.metricdata.bits);
else get(handles.radio_Minorder,'Value')==1
sound(handles.metricdata.after,handles.metricdata.FSs,handles.metricdata.bits);
end
% --- Executes on button press in pushbutton_show.
function pushbutton_show_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton_show (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
lg=length(handles.metricdata.before);
lgs=[0:lg-1];
befores=fft(handles.metricdata.before);
if get(handles.radio_fir,'Value')==1
after=fftfilt(handles.metricdata.b,handles.metricdata.before);
else after=filter(handles.metricdata.b,handles.metricdata.a,handles.metricdata.before);
end
afters=fft(after);
figure;subplot(2,2,1);plot(handles.metricdata.before);
subplot(2,2,2);plot(after);
subplot(2,2,3);stem(lgs,befores);
subplot(2,2,4);stem(lgs,afters);
handles.metricdata.after = after;
guidata(hObject,handles)
% --- Executes on mouse press over figure background.
function figure1_ButtonDownFcn(hObject, eventdata, handles)
% hObject handle to figure1 (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 pushbutton_filter.
function pushbutton_filter_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton_filter (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -