📄 patchui2.m
字号:
function varargout = PatchUI2(varargin)% PATCHUI2 M-file for PatchUI2.fig% PATCHUI2, by itself, creates a new PATCHUI2 or raises the existing% singleton*.%% H = PATCHUI2 returns the handle to a new PATCHUI2 or the handle to% the existing singleton*.%% PATCHUI2('CALLBACK',hObject,eventData,handles,...) calls the local% function named CALLBACK in PATCHUI2.M with the given input arguments.%% PATCHUI2('Property','Value',...) creates a new PATCHUI2 or raises the% existing singleton*. Starting from the left, property value pairs are% applied to the GUI before PatchUI2_OpeningFcn gets called. An% unrecognized property name or invalid value makes property application% stop. All inputs are passed to PatchUI2_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 PatchUI2% Last Modified by GUIDE v2.5 18-Mar-2008 21:04:43% Begin initialization code - DO NOT EDITgui_Singleton = 1;gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @PatchUI2_OpeningFcn, ... 'gui_OutputFcn', @PatchUI2_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 PatchUI2 is made visible.function PatchUI2_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 PatchUI2 (see VARARGIN)% Choose default command line output for PatchUI2handles.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 PatchUI2. global A B C D E F H ts dz dy dx er fftstart fftstop A=5; B=6; C=20; D=0; E=0; F=40; H=3; ts=3000; dz=0.265; dy=.4; dx=.389; er=2.2; fftstart=0.1; fftstop=10; axes(handles.axes2); rgb=imread('Patch.jpg'); image(rgb); axis off;% UIWAIT makes PatchUI2 wait for user response (see UIRESUME)% uiwait(handles.figure1);% --- Outputs from this function are returned to the command line.function varargout = PatchUI2_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 H ts dz dy dx er fftstart fftstoph1=findobj('Tag','text10');set(h1,'String', 'Running');t0 = clock;if ((A+B+C) < 51) system(sprintf('set BRT_RUNTIME=dx9 & 3dpatch.exe %.0d %0.4f %0.4f %0.4f %s %s %s %s %s %s %s %2.3f', ts, dx, dy, dz, num2str(A), num2str(B), num2str(C), num2str(D), num2str(F), num2str(E), num2str(H), er)) clear obs; load obs.txt; clear v1; clear Istrip1; v1=obs(:,1); Istrip1=obs(:,2); c=2.99792479*10^8; dt=.9/sqrt((c/(dx*10^-3))^2+(c/(dy*10^-3))^2+(c/(dz*10^-3))^2)% dt=5.766999e-13; [vf,fc,nf]=ADFT(v1,ts,dt,fftstart,fftstop,.05); % Atef added minus sign to the time domain current [iff,fc,nf]=ADFT(-Istrip1,ts,dt,fftstart,fftstop,.05); % Atef - sign removed from the s11 expression zf=vf./iff; sf=20*log10(abs((zf-50)./(zf+50))); h1=figure; plot(fc,sf, 'LineWidth', 2); grid on; legend('S11'); xlabel('Freq - GHz'); ylabel('S11 - dB'); title('S11 vs Frequency'); h1=figure; plot((1:ts)*dt,v1, 'LineWidth', 2); grid on; legend('Voltage'); xlabel('Time (s)'); ylabel('Voltage (V)'); title('Port Voltage vs Time'); h1=figure; plot((1:ts)*dt,Istrip1, 'LineWidth', 2); grid on; legend('Current'); xlabel('Time (s)'); ylabel('current (A)'); title('Port Currrent vs Time'); h1=figure; % modified by Atef 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('Antenna Input Impedance vs Frequency'); % end modifications h1=findobj('Tag','text10');set(h1,'String', ['Runtime - ' num2str(etime(clock,t0)) ' s']);else f = errordlg('Simulation Size To Big - A+B+C Must 50 Cells or Less', 'Error Dialog');end% --------------------------------------------------------------------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));% --- 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]);endsetspace;% --- 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'));% --- Executes during object creation, after setting all properties.function edit1_CreateFcn(hObject, eventdata, handles)% hObject handle to edit1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -