📄 lowpass.m
字号:
end
%-----------------------------------------------------------------
function [b,a,n]=bandstopfilter(fs,wp,ws,rp,rs,as,ap,point)
lowpass_sel_index = point;
switch lowpass_sel_index
case 1
[n,wn]=buttord([wp/fs/2 ws/fs/2],[rp/fs/2,rs/fs/2],ap,as);
[b,a]=butter(n,wn,'stop');
case 2
[n,wn]=cheb1ord([wp/fs/2 ws/fs/2],[rp/fs/2,rs/fs/2],ap,as);
[b,a]=cheby1(n,ap,wn,'stop');
case 3
[n,wn]=cheb2ord([wp/fs/2 ws/fs/2],[rp/fs/2,rs/fs/2],ap,as);
[b,a]=cheby2(n,ap,wn,'stop');
case 4
[n,wn]=ellipord([wp/fs/2 ws/fs/2],[rp/fs/2,rs/fs/2],ap,as);
[b,a]=ellip(n,ap,as,wn,'stop');
end
function Hf_fs_CreateFcn(hObject, eventdata, handles)
% hObject handle to Hf_fs (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 Hf_fs_Callback(hObject, eventdata, handles)
% hObject handle to Hf_fs (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 Hf_fs as text
% str2double(get(hObject,'String')) returns contents of Hf_fs as a double
fs=str2double(get(handles.Hf_fs,'String'));
% --- Executes during object creation, after setting all properties.
function Hp_popup_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','Eliptic'});
% --- Executes on selection change in popupmenu2.
function Hp_popup_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 on button press in Hl_low.
function Hl_low_Callback(hObject, eventdata, handles)
% hObject handle to Hl_low (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 Hl_low
set(handles.Hl_low, 'Value', 1);
set(handles.Hh_high, 'Value', 0);
set(handles.Hb_bandpass, 'Value', 0);
set(handles.Hb_bandstop, 'Value', 0);
set(handles.Hr_rstop1, 'Visible', 'off');
set(handles.Hr_rpass, 'Visible', 'off');
set(handles.Hr_rstop2, 'Visible', 'off');
set(handles.text23, 'Visible', 'off');
set(handles.text24, 'Visible', 'off');
set(handles.text25, 'Visible', 'off');
set(handles.text5, 'String', 'wp');
set(handles.text6, 'String', 'ws');
set(handles.text3, 'String', 'rp');
set(handles.text4, 'String', 'rs');
% --- Executes on button press in Hh_high.
function Hh_high_Callback(hObject, eventdata, handles)
% hObject handle to Hh_high (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 Hh_high
set(handles.Hl_low, 'Value', 0);
set(handles.Hh_high, 'Value', 1);
set(handles.Hb_bandpass, 'Value', 0);
set(handles.Hb_bandstop, 'Value', 0);
set(handles.Hr_rstop1, 'Visible', 'off');
set(handles.Hr_rpass, 'Visible', 'off');
set(handles.Hr_rstop2, 'Visible', 'off');
set(handles.text23, 'Visible', 'off');
set(handles.text24, 'Visible', 'off');
set(handles.text25, 'Visible', 'off');
set(handles.text5, 'String', 'wp');
set(handles.text6, 'String', 'ws');
set(handles.text3, 'String', 'rp');
set(handles.text4, 'String', 'rs');
% --- Executes on button press in Hb_bandpass.
function Hb_bandpass_Callback(hObject, eventdata, handles)
% hObject handle to Hb_bandpass (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 Hb_bandpass
set(handles.Hl_low, 'Value', 0);
set(handles.Hh_high, 'Value', 0);
set(handles.Hb_bandpass, 'Value', 1);
set(handles.Hb_bandstop, 'Value', 0);
set(handles.text5, 'String', 'Fpass1');
set(handles.text6, 'String', 'Fpass2');
set(handles.text3, 'String', 'Fstop1');
set(handles.text4, 'String', 'Fstop2');
set(handles.Hr_rstop1, 'Visible', 'on');
set(handles.Hr_rpass, 'Visible', 'on');
set(handles.Hr_rstop2, 'Visible', 'on');
set(handles.text23, 'Visible', 'on');
set(handles.text24, 'Visible', 'on');
set(handles.text25, 'Visible', 'on');
set(handles.text23, 'String', 'Rstop1');
set(handles.text24, 'String', 'Rpass');
set(handles.text25, 'String', 'Rstop2');
% --- Executes on button press in Hb_bandstop.
function Hb_bandstop_Callback(hObject, eventdata, handles)
% hObject handle to Hb_bandstop (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 Hb_bandstop
set(handles.Hl_low, 'Value', 0);
set(handles.Hh_high, 'Value', 0);
set(handles.Hb_bandpass, 'Value', 0);
set(handles.Hb_bandstop, 'Value', 1);
set(handles.text5, 'String', 'Fpass1');
set(handles.text6, 'String', 'Fpass2');
set(handles.text3, 'String', 'Fstop1');
set(handles.text4, 'String', 'Fstop2');
set(handles.text23, 'String', 'Rpass1');
set(handles.text24, 'String', 'Rstop');
set(handles.text25, 'String', 'Rpass2');
set(handles.Hr_rstop1, 'Visible', 'on');
set(handles.Hr_rpass, 'Visible', 'on');
set(handles.Hr_rstop2, 'Visible', 'on');
set(handles.text23, 'Visible', 'on');
set(handles.text24, 'Visible', 'on');
set(handles.text25, 'Visible', 'on');
% --- Executes during object creation, after setting all properties.
function Hf_fs1_CreateFcn(hObject, eventdata, handles)
% hObject handle to Hf_fs1 (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 Hf_fs1_Callback(hObject, eventdata, handles)
% hObject handle to Hf_fs1 (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 Hf_fs1 as text
% str2double(get(hObject,'String')) returns contents of Hf_fs1 as a double
% --- Executes during object creation, after setting all properties.
function Hp_pass1_CreateFcn(hObject, eventdata, handles)
% hObject handle to Hp_pass1 (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 Hp_pass1_Callback(hObject, eventdata, handles)
% hObject handle to Hp_pass1 (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 Hp_pass1 as text
% str2double(get(hObject,'String')) returns contents of Hp_pass1 as a double
% --- Executes during object creation, after setting all properties.
function Hf_fpass2_CreateFcn(hObject, eventdata, handles)
% hObject handle to Hf_fpass2 (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 Hf_fpass2_Callback(hObject, eventdata, handles)
% hObject handle to Hf_fpass2 (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 Hf_fpass2 as text
% str2double(get(hObject,'String')) returns contents of Hf_fpass2 as a double
% --- Executes during object creation, after setting all properties.
function Hf_stop_CreateFcn(hObject, eventdata, handles)
% hObject handle to Hf_stop (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 Hf_stop_Callback(hObject, eventdata, handles)
% hObject handle to Hf_stop (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 Hf_stop as text
% str2double(get(hObject,'String')) returns contents of Hf_stop as a double
% --- Executes during object creation, after setting all properties.
function Hf_rp1_CreateFcn(hObject, eventdata, handles)
% hObject handle to Hf_rp1 (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 Hf_rp1_Callback(hObject, eventdata, handles)
% hObject handle to Hf_rp1 (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 Hf_rp1 as text
% str2double(get(hObject,'String')) returns contents of Hf_rp1 as a double
% --- Executes during object creation, after setting all properties.
function Hr_rp2_CreateFcn(hObject, eventdata, handles)
% hObject handle to Hr_rp2 (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
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -