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

📄 h_df.asv

📁 很多matlab的源代码
💻 ASV
字号:
function varargout = h_df(varargin)
% H_DF M-file for h_df.fig
%      H_DF, by itself, creates a new H_DF or raises the existing
%      singleton*.
%
%      H = H_DF returns the handle to a new H_DF or the handle to
%      the existing singleton*.
%
%      H_DF('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in H_DF.M with the given input arguments.
%
%      H_DF('Property','Value',...) creates a new H_DF or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before h_df_OpeningFunction gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to h_df_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 h_df

% Last Modified by GUIDE v2.5 07-Jun-2004 23:19:15
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @h_df_OpeningFcn, ...
                   'gui_OutputFcn',  @h_df_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 h_df is made visible.
function h_df_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 h_df (see VARARGIN)

% Choose default command line output for h_df
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes h_df wait for user response (see UIRESUME)
% uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = h_df_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 during object creation, after setting all properties.function Rp_value_CreateFcn(hObject, eventdata, handles)% hObject    handle to Rp_value (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'));endfunction Rp_value_Callback(hObject, eventdata, handles)% hObject    handle to Rp_value (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 Rp_value as text%        str2double(get(hObject,'String')) returns contents of Rp_value as a double% --- Executes during object creation, after setting all properties.function Rs_value_CreateFcn(hObject, eventdata, handles)% hObject    handle to Rs_value (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'));endfunction Rs_value_Callback(hObject, eventdata, handles)% hObject    handle to Rs_value (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 Rs_value as text%        str2double(get(hObject,'String')) returns contents of Rs_value as a double% --- Executes during object creation, after setting all properties.function Fs_value_CreateFcn(hObject, eventdata, handles)% hObject    handle to Fs_value (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'));endfunction Fs_value_Callback(hObject, eventdata, handles)% hObject    handle to Fs_value (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 Fs_value as text%        str2double(get(hObject,'String')) returns contents of Fs_value as a double% --- Executes on button press in test.function test_Callback(hObject, eventdata, handles)% hObject    handle to test (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)Wp=2*pi*str2num(get(handles.p_frequency,'string'));

Wp=2*pi*30;
Ws=2*pi*40;
%Rp=0.5; Rs=40; Fs=500;
Rp=str2num(get(handles.Rp_value,'string'));
Rs=str2num(get(handles.Rs_value,'string'));
Fs=str2num(get(handles.Fs_value,'string'));
%选择滤波器的阶数
[N,Wn]=buttord(Wp,Ws,Rp,Rs,'s');
%创建Butterworth低通滤波器原型
[z,p,k]=buttap(N);
%从零极点形式转换成状态方程形式
[A,B,C,D]=zp2ss(z,p,k);
%实现低通到高通滤波器类型的转换
[At,Bt,Ct,Dt]=lp2hp(A,B,C,D,Wn);
%采用双线性变换法实现从模拟低通到数字高通滤波器的转换
[b,a]=ss2tf(At,Bt,Ct,Dt);
[b1,a1]=bilinear(b,a,Fs);
%绘出频率响应曲线
axes(handles.axes1);
[h,w]=freqz(b1,a1);
plot(w*Fs/(2*pi),abs(h));
grid;
xlabel('频率(Hz)');
ylabel('幅值');
title('Highpass digital filter');
axes(handles.axes2);
plot(w*Fs/(2*pi),20*log10(abs(h)));
grid;
xlabel('频率(Hz)');
ylabel('幅值(dB)');
title('Highpass digital filter');% --- Executes on button press in clear.function clear_Callback(hObject, eventdata, handles)% hObject    handle to clear (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)set(handles.Rp_value,'string','');
set(handles.Rs_value,'string','');
set(handles.Fs_value,'string','');% --- Executes during object creation, after setting all properties.function p_frequency_CreateFcn(hObject, eventdata, handles)% hObject    handle to p_frequency (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'));endfunction p_frequency_Callback(hObject, eventdata, handles)% hObject    handle to p_frequency (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 p_frequency as text%        str2double(get(hObject,'String')) returns contents of p_frequency as a double% --- Executes during object creation, after setting all properties.function s_frequency_CreateFcn(hObject, eventdata, handles)% hObject    handle to s_frequency (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'));endfunction s_frequency_Callback(hObject, eventdata, handles)% hObject    handle to s_frequency (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 s_frequency as text%        str2double(get(hObject,'String')) returns contents of s_frequency as a double

⌨️ 快捷键说明

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