📄 filterui.m
字号:
function varargout = FilterUI(varargin)% FilterUI M-file for FilterUI.fig% FilterUI, by itself, creates a new FilterUI or raises the existing% singleton*.%% H = FilterUI returns the handle to a new FilterUI or the handle to% the existing singleton*.%% FilterUI('CALLBACK',hObject,eventData,handles,...) calls the local% function named CALLBACK in FilterUI.M with the given input arguments.%% FilterUI('Property','Value',...) creates a new FilterUI or raises the% existing singleton*. Starting from the left, property value pairs are% applied to the GUI before FilterUI_OpeningFcn gets called. An% unrecognized property name or invalid value makes property application% stop. All inputs are passed to FilterUI_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 FilterUI% Last Modified by GUIDE v2.5 30-Apr-2008 13:45:11% Begin initialization code - DO NOT EDITgui_Singleton = 1;gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @FilterUI_OpeningFcn, ... 'gui_OutputFcn', @FilterUI_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []);if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1});endif 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 FilterUI is made visible.function FilterUI_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 FilterUI (see VARARGIN)% Choose default command line output for FilterUIhandles.output = hObject;% Update handles structureguidata(hObject, handles);% This sets up the initial plot - only do when we are invisible% so window can get raised using FilterUI. global A B C D E F G ts dx dy dz er fftstart fftstop fftstart=0.1; fftstop=20; A=6; B=13; C=6; D=10; E=6; F=13; G=3; ts=2000; dx=0.4233; dy=0.4064; dz=0.265; er=2.2; axes(handles.axes4); rgb=imread('Filter.jpg'); image(rgb); axis off; setspace; % UIWAIT makes FilterUI wait for user response (see UIRESUME)% uiwait(handles.figure1);% --- Outputs from this function are returned to the command line.function varargout = FilterUI_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 structurevarargout{1} = handles.output;% --- Executes on button press in pushbutton1.function pushbutton1_Callback(hObject, eventdata, handles)% hObject handle to pushbutton1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)global A B C D E F G ts dx dy dz er fftstart fftstoph1=findobj('Tag','text10');set(h1,'String', 'Running');t0 = clock;clear port port2 V1 I1 V2 I2sprintf('set BRT_RUNTIME=dx9 & 3dfilter.exe %.0d %2.3f %0.4f %0.4f %0.4f %s %s %s %s %s %s %s', ts, er, dx, dy, dz, num2str(B), num2str(C), num2str(D), num2str(E), num2str(F), num2str(A), num2str(G))system(sprintf('set BRT_RUNTIME=dx9 & 3dfilter.exe %.0d %2.3f %0.4f %0.4f %0.4f %s %s %s %s %s %s %s', ts, er, dx, dy, dz, num2str(B), num2str(C), num2str(D), num2str(E), num2str(F), num2str(A), num2str(G)))dt=5.899437e-13;load port.txt;V1=port(:,1);I1=-port(:,2);load port2.txt;V2=port2(:,1);I2=-port2(:,2);n=ts; [vf,fc,nf]=ADFT(V1,n,dt,fftstart,fftstop,.1); [iff,fc,nf]=ADFT(I1,n,dt,fftstart,fftstop,.1); [vf2,fc,nf]=ADFT(V2,n,dt,fftstart,fftstop,.1); [iff2,fc,nf]=ADFT(I2,n,dt,fftstart,fftstop,.1); zf=vf./iff; zf2=vf2./iff2; sf=abs((zf-50)./(zf+50)); sf2=abs((zf2-50)./(zf2+50)); a1=((vf+50.*iff)./(2.*sqrt(50))); b1=((vf-50.*iff)./(2.*sqrt(50))); a2=((vf2+50.*iff2)./(2.*sqrt(50))); b2=((vf2-50.*iff2)./(2.*sqrt(50))); h1=figure; plot(fc,20*log10(abs(b1./a1)), 'LineWidth', 2); legend('S11'); xlabel('Freq - GHz'); ylabel('S11 - dB'); title('S11 vs Frequency'); grid on; h1=figure; plot(fc,20*log10(abs(a2./a1)), 'LineWidth', 2); legend('S21'); xlabel('Freq - GHz'); ylabel('S21 - dB'); title('S21 vs Frequency'); grid on; h1=figure; plot((1:ts)*dt,V1,'b-',(1:ts)*dt,V2,'r:', 'LineWidth', 2); grid on; legend('Port 1', 'Port 2'); xlabel('Time (s)'); ylabel('Voltage (V)'); title('Port Voltage vs Time'); h1=figure; plot((1:ts)*dt,I1,'b-',(1:ts)*dt,I2,'r:', 'LineWidth', 2); grid on; legend('Port 1', 'Port 2'); xlabel('Time (s)'); ylabel('Current (A)'); title('Port Current vs Time'); h1=figure; plot(fc,real(zf),'b-',fc,imag(zf),'r:', 'LineWidth', 2); grid on; legend('Z_{in} Real','Z_{in} Imag'); xlabel('Freq - GHz'); ylabel('Z_{in} - Ohms'); title('Filter Input Impedance vs Frequency'); h1=findobj('Tag','text10');set(h1,'String', ['Runtime - ' num2str(etime(clock,t0)) ' s']);% --------------------------------------------------------------------function FileMenu_Callback(hObject, eventdata, handles)% hObject handle to FileMenu (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% --------------------------------------------------------------------function OpenMenuItem_Callback(hObject, eventdata, handles)% hObject handle to OpenMenuItem (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)file = uigetfile('*.fig');if ~isequal(file, 0) open(file);end% --------------------------------------------------------------------function PrintMenuItem_Callback(hObject, eventdata, handles)% hObject handle to PrintMenuItem (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)printdlg(handles.figure1)% --------------------------------------------------------------------function CloseMenuItem_Callback(hObject, eventdata, handles)% hObject handle to CloseMenuItem (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)selection = questdlg(['Close ' get(handles.figure1,'Name') '?'],... ['Close ' get(handles.figure1,'Name') '...'],... 'Yes','No','Yes');if strcmp(selection,'No') return;enddelete(handles.figure1)% --- Executes on slider movement.function slider1_Callback(hObject, eventdata, handles)% hObject handle to slider1 (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,'Value') returns position of slider% get(hObject,'Min') and get(hObject,'Max') to determine range of sliderglobal CC= round(get(hObject,'Value'));set(hObject,'Value', C);h1=findobj('Tag','text8');set(h1,'String', num2str(C));setspace;% --- Executes during object creation, after setting all properties.function slider1_CreateFcn(hObject, eventdata, handles)% hObject handle to slider1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called% Hint: slider controls usually have a light gray background.if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor',[.9 .9 .9]);end% --- Executes on slider movement.function slider2_Callback(hObject, eventdata, handles)% hObject handle to slider2 (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,'Value') returns position of slider% get(hObject,'Min') and get(hObject,'Max') to determine range of sliderglobal DD= round(get(hObject,'Value'));set(hObject,'Value', D);h1=findobj('Tag','text9');set(h1,'String', num2str(D));setspace;% --- Executes during object creation, after setting all properties.function slider2_CreateFcn(hObject, eventdata, handles)% hObject handle to slider2 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called% Hint: slider controls usually have a light gray background.if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor',[.9 .9 .9]);end% --- Executes on slider movement.function slider3_Callback(hObject, eventdata, handles)% hObject handle to slider3 (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,'Value') returns position of slider% get(hObject,'Min') and get(hObject,'Max') to determine range of sliderglobal AA= round(get(hObject,'Value'));set(hObject,'Value', A);h1=findobj('Tag','text6');set(h1,'String', num2str(A));setspace;% --- Executes during object creation, after setting all properties.function slider3_CreateFcn(hObject, eventdata, handles)% hObject handle to slider3 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called% Hint: slider controls usually have a light gray background.if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor',[.9 .9 .9]);end% --- Executes on slider movement.function slider4_Callback(hObject, eventdata, handles)% hObject handle to slider4 (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,'Value') returns position of slider% get(hObject,'Min') and get(hObject,'Max') to determine range of sliderglobal BB= round(get(hObject,'Value'));set(hObject,'Value', B);h1=findobj('Tag','text7');set(h1,'String', num2str(B));setspace;% --- Executes during object creation, after setting all properties.function slider4_CreateFcn(hObject, eventdata, handles)% hObject handle to slider4 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called% Hint: slider controls usually have a light gray background.if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor',[.9 .9 .9]);endfunction edit1_Callback(hObject, eventdata, handles)% hObject handle to edit1 (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 edit1 as text% str2double(get(hObject,'String')) returns contents of edit1 as a doubleglobal tsts = str2num(get(hObject,'String'));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -