📄 eqfilters.html
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"><html xmlns:mwsh="http://www.mathworks.com/namespace/mcode/v1/syntaxhighlight.dtd"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <!--This HTML is auto-generated from an M-file.To make changes, update the M-file and republish this document. --> <title>Main GUI file</title> <meta name="generator" content="MATLAB 7.4"> <meta name="date" content="2008-05-08"> <meta name="m-file" content="EQFilters"><style>body { background-color: white; margin:10px;}h1 { color: #990000; font-size: x-large;}h2 { color: #990000; font-size: medium;}/* Make the text shrink to fit narrow windows, but not stretch too far in wide windows. */ p,h1,h2,div.content div { max-width: 600px; /* Hack for IE6 */ width: auto !important; width: 600px;}pre.codeinput { background: #EEEEEE; padding: 10px;}@media print { pre.codeinput {word-wrap:break-word; width:100%;}} span.keyword {color: #0000FF}span.comment {color: #228B22}span.string {color: #A020F0}span.untermstring {color: #B20000}span.syscmd {color: #B28C00}pre.codeoutput { color: #666666; padding: 10px;}pre.error { color: red;}p.footer { text-align: right; font-size: xx-small; font-weight: lighter; font-style: italic; color: gray;} </style></head> <body> <div class="content"> <h1>Main GUI file</h1> <introduction></introduction> <h2>Contents</h2> <div> <ul> <li><a href="#3">Logging</a></li> <li><a href="#5">Parameter and component calculations</a></li> <li><a href="#8">Magnitude plot menu item</a></li> <li><a href="#9">Phase plot menu item</a></li> <li><a href="#11">Write SPICE file menu item</a></li> <li><a href="#13">Low frequency input</a></li> <li><a href="#15">High frequency input</a></li> <li><a href="#16">Number of filters input</a></li> <li><a href="#17">Quality input</a></li> <li><a href="#19">Passband gain input</a></li> <li><a href="#21">Minimum resistor value</a></li> <li><a href="#23">Maximum capacitor value</a></li> <li><a href="#25">Minimum capacitor value</a></li> <li><a href="#26">Maximum capacitor value</a></li> </ul> </div> <p>Most of this was created by GUIDE, so comments will be sparse.</p><pre class="codeinput"><span class="keyword">function</span> varargout = EQFilters(varargin)</pre><p>EQFILTERS M-file for EQFilters.fig EQFILTERS, by itself, creates a new EQFILTERS or raises the existing singleton*.</p><pre> H = EQFILTERS returns the handle to a new EQFILTERS or the handle to the existing singleton*.</pre><pre> EQFILTERS('CALLBACK',hObject,eventData,handles,...) calls the local function named CALLBACK in EQFILTERS.M with the given input arguments.</pre><pre> EQFILTERS('Property','Value',...) creates a new EQFILTERS or raises the existing singleton*. Starting from the left, property value pairs are applied to the GUI before EQFilters_OpeningFunction gets called. An unrecognized property name or invalid value makes property application stop. All inputs are passed to EQFilters_OpeningFcn via varargin.</pre><pre> *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one instance to run (singleton)".</pre><p>See also: GUIDE, GUIDATA, GUIHANDLES</p><pre class="codeinput"><span class="comment">% Edit the above text to modify the response to help EQFilters</span><span class="comment">% Last Modified by GUIDE v2.5 04-Apr-2008 10:53:44</span><span class="comment">% Begin initialization code - DO NOT EDIT</span>gui_Singleton = 1;gui_State = struct(<span class="string">'gui_Name'</span>, mfilename, <span class="keyword">...</span> <span class="string">'gui_Singleton'</span>, gui_Singleton, <span class="keyword">...</span> <span class="string">'gui_OpeningFcn'</span>, @EQFilters_OpeningFcn, <span class="keyword">...</span> <span class="string">'gui_OutputFcn'</span>, @EQFilters_OutputFcn, <span class="keyword">...</span> <span class="string">'gui_LayoutFcn'</span>, [] , <span class="keyword">...</span> <span class="string">'gui_Callback'</span>, []);<span class="keyword">if</span> nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1});<span class="keyword">end</span><span class="keyword">if</span> nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});<span class="keyword">else</span> gui_mainfcn(gui_State, varargin{:});<span class="keyword">end</span><span class="comment">% End initialization code - DO NOT EDIT</span><span class="comment">% --- Executes just before EQFilters is made visible.</span><span class="keyword">function</span> EQFilters_OpeningFcn(hObject, eventdata, handles, varargin)<span class="comment">% This function has no output args, see OutputFcn.</span><span class="comment">% hObject handle to figure</span><span class="comment">% eventdata reserved - to be defined in a future version of MATLAB</span><span class="comment">% handles structure with handles and user data (see GUIDATA)</span><span class="comment">% varargin command line arguments to EQFilters (see VARARGIN)</span><span class="comment">% Choose default command line output for EQFilters</span>handles.output = hObject;<span class="comment">% Update handles structure</span>guidata(hObject, handles);<span class="comment">% UIWAIT makes EQFilters wait for user response (see UIRESUME)</span><span class="comment">% uiwait(handles.figure1);</span><span class="comment">% --- Outputs from this function are returned to the command line.</span><span class="keyword">function</span> varargout = EQFilters_OutputFcn(hObject, eventdata, handles)<span class="comment">% varargout cell array for returning output args (see VARARGOUT);</span><span class="comment">% hObject handle to figure</span><span class="comment">% eventdata reserved - to be defined in a future version of MATLAB</span><span class="comment">% handles structure with handles and user data (see GUIDATA)</span><span class="comment">% Get default command line output from handles structure</span>varargout{1} = handles.output;<span class="comment">% --- Executes on button press in pushbutton1.</span><span class="keyword">function</span> pushbutton1_Callback(hObject, eventdata, handles)<span class="comment">% hObject handle to pushbutton1 (see GCBO)</span><span class="comment">% eventdata reserved - to be defined in a future version of MATLAB</span><span class="comment">% handles structure with handles and user data (see GUIDATA)</span> <span class="keyword">global</span> lowest_freq <span class="keyword">global</span> highest_freq <span class="keyword">global</span> q0; <span class="keyword">global</span> n_filters; <span class="keyword">global</span> hbp; <span class="keyword">global</span> r1; <span class="keyword">global</span> r2; <span class="keyword">global</span> r5; <span class="keyword">global</span> c3; <span class="keyword">global</span> c4; <span class="keyword">global</span> w0; <span class="keyword">global</span> options;</pre><h2>Logging<a name="3"></a></h2> <p>The time of the calculation is logged. This is fairly worthless, but could be expanded in a later version.</p><pre class="codeinput"> D = now; date_time = datestr(D,0); f = fopen(strcat(cd,<span class="string">'/EQ_gen_log.txt'</span>),<span class="string">'a'</span>); fprintf(f,<span class="string">'Time Start '</span>); fprintf(f,date_time); fprintf(f,<span class="string">'\n\n'</span>);</pre><h2>Parameter and component calculations<a name="5"></a></h2> <p>First, the filter parameters are calculated based on the user input, then the comopnents are calculated. Both of these actions are recorded to the log, and an error message, if applicable, is displayed. </p><pre class="codeinput"> fprintf(f,<span class="string">'Calculating filter parameters...\n'</span>); [w0,q0,hbp,n] = calc_parameters(lowest_freq,highest_freq,q0,hbp,n_filters) fprintf(f,<span class="string">'Calulating component values....\n'</span>); [r1,r2,r5,c3,c4,error_msg] = calc_components(q0,w0,hbp,options) <span class="keyword">if</span>(length(error_msg) > 93) errordlg(error_msg,<span class="string">'Try changing the options...'</span>,<span class="string">'modal'</span>); fprintf(f,<span class="string">'Error: '</span>); fprintf(f,error_msg); fprintf(f,<span class="string">'\n'</span>); <span class="keyword">end</span></pre><pre class="codeinput"><span class="comment">% --------------------------------------------------------------------</span><span class="keyword">function</span> plots_top_Callback(hObject, eventdata, handles)<span class="comment">% hObject handle to plots_top (see GCBO)</span><span class="comment">% eventdata reserved - to be defined in a future version of MATLAB</span><span class="comment">% handles structure with handles and user data (see GUIDATA)</span></pre><h2>Magnitude plot menu item<a name="8"></a></h2> <p>--------------------------------------------------------------------</p><pre class="codeinput"><span class="keyword">function</span> mag_plot_Callback(hObject, eventdata, handles, x, y)<span class="comment">% hObject handle to mag_plot (see GCBO)</span><span class="comment">% eventdata reserved - to be defined in a future version of MATLAB</span><span class="comment">% handles structure with handles and user data (see GUIDATA)</span> <span class="keyword">global</span> q0; <span class="keyword">global</span> n_filters; <span class="keyword">global</span> hbp; <span class="keyword">global</span> w0; [filter_mag,filter_phase,w0_vector] = calc_transfer(w0,q0,hbp,n_filters); mag_plot_handle = figure; semilogx(w0_vector/(2*pi),20*log10(filter_mag)); xlabel(<span class="string">'Frequency (Hz)'</span>); ylabel(<span class="string">'Magnitude (dB)'</span>); title(<span class="string">'Output Magnitude vs. Frequency'</span>);<span class="comment">% --------------------------------------------------------------------</span></pre><h2>Phase plot menu item<a name="9"></a></h2><pre class="codeinput"><span class="keyword">function</span> phase_plot_Callback(hObject, eventdata, handles)<span class="comment">% hObject handle to phase_plot (see GCBO)</span><span class="comment">% eventdata reserved - to be defined in a future version of MATLAB</span><span class="comment">% handles structure with handles and user data (see GUIDATA)</span> <span class="keyword">global</span> q0; <span class="keyword">global</span> n_filters; <span class="keyword">global</span> hbp; <span class="keyword">global</span> w0; [filter_mag,filter_phase,w0_vector] = calc_transfer(w0,q0,hbp,n_filters); phase_plot_handle = figure; semilogx(w0_vector/(2*pi),filter_phase); xlabel(<span class="string">'Frequency (Hz)'</span>); ylabel(<span class="string">'Phase (rads)'</span>); title(<span class="string">'Filter Phase vs. Frequency'</span>);</pre><p>--------------------------------------------------------------------</p><pre class="codeinput"><span class="keyword">function</span> spice_top_Callback(hObject, eventdata, handles)<span class="comment">% hObject handle to spice_top (see GCBO)</span><span class="comment">% eventdata reserved - to be defined in a future version of MATLAB</span><span class="comment">% handles structure with handles and user data (see GUIDATA)</span></pre><h2>Write SPICE file menu item<a name="11"></a></h2> <p>--------------------------------------------------------------------</p><pre class="codeinput"><span class="keyword">function</span> gen_net_Callback(hObject, eventdata, handles)<span class="comment">% hObject handle to gen_net (see GCBO)</span><span class="comment">% eventdata reserved - to be defined in a future version of MATLAB</span><span class="comment">% handles structure with handles and user data (see GUIDATA)</span> <span class="keyword">global</span> r1; <span class="keyword">global</span> r2; <span class="keyword">global</span> r5; <span class="keyword">global</span> c3; <span class="keyword">global</span> c4; <span class="keyword">global</span> w0; <span class="keyword">global</span> n_filters; f = fopen(strcat(cd,<span class="string">'/EQ_gen_log.txt'</span>),<span class="string">'a'</span>); fprintf(f,<span class="string">'Generating SPICE file...\n'</span>); write_spice_file(r1,r2,r5,c3,c4,w0,n_filters)</pre><pre class="codeinput"><span class="comment">% --------------------------------------------------------------------</span><span class="keyword">function</span> help_Callback(hObject, eventdata, handles)<span class="comment">% hObject handle to help (see GCBO)</span><span class="comment">% eventdata reserved - to be defined in a future version of MATLAB</span><span class="comment">% handles structure with handles and user data (see GUIDATA)</span><span class="comment">% --------------------------------------------------------------------</span><span class="keyword">function</span> online_manual_Callback(hObject, eventdata, handles)<span class="comment">% hObject handle to online_manual (see GCBO)</span><span class="comment">% eventdata reserved - to be defined in a future version of MATLAB</span><span class="comment">% handles structure with handles and user data (see GUIDATA)</span><span class="comment">% --------------------------------------------------------------------</span><span class="keyword">function</span> about_Callback(hObject, eventdata, handles)<span class="comment">% hObject handle to about (see GCBO)</span><span class="comment">% eventdata reserved - to be defined in a future version of MATLAB</span><span class="comment">% handles structure with handles and user data (see GUIDATA)</span></pre><h2>Low frequency input<a name="13"></a></h2><pre class="codeinput"><span class="comment">%For this input, the string is converted to a double, and validated.</span><span class="comment">%**************************************************************************</span><span class="comment">%Low Freq Input Callback function:</span><span class="comment">%**************************************************************************</span>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -