From 5a882a7085b41c9bec49449c465eee873f6358fc Mon Sep 17 00:00:00 2001 From: Georg Michel Date: Thu, 23 Mar 2017 21:10:50 +0100 Subject: [PATCH] added an option to set the markers manually --- matlab/plotRefl.m | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/matlab/plotRefl.m b/matlab/plotRefl.m index 5f88631..441c336 100644 --- a/matlab/plotRefl.m +++ b/matlab/plotRefl.m @@ -18,9 +18,11 @@ function h = plotRefl(port, varargin) % for the frequency (always in MHz), default is 0 % 'threshold': - Threshold value (in dB) for the upper and lower % cutoff frequency, default is -3 +% 'fmarkers': - set lower and upper frequency marker in Hz manually, +% like so: [4e9, 6.5e9] % example: % myport = calcPort(myport, Sim_Path, linspace(f_0-f_c, f_0+f_c, 200)); -% plotRefl(myport); +% plotRefl(myport, 'fmarkers', [4e9, 6.5e9]); % % See also calcPort % @@ -31,14 +33,16 @@ function h = plotRefl(port, varargin) %defaults precision = 0; threshold = -3; - +fmarkers = []; for n=1:2:numel(varargin) if (strcmp(varargin{n},'precision')==1); precision = varargin{n+1}; elseif (strcmp(varargin{n},'threshold')==1); threshold = varargin{n+1}; - else + elseif (strcmp(varargin{n},'fmarkers')==1); + fmarkers = varargin{n+1}; + else warning('openEMS:polarFF',['unknown argument key: ''' varargin{n} '''']); end end @@ -111,8 +115,14 @@ text (real (rho), imag (rho), '0'); s11dB = 20*log10(abs(s11)); +if(isempty(fmarkers)) upperind = s11dB(1:end-1) < threshold & s11dB(2:end) > threshold; lowerind = s11dB(1:end-1) > threshold & s11dB(2:end) < threshold; +else +upperind = [nthargout(2, @min, abs(fmarkers(2)-port.f))]; +lowerind = [nthargout(2, @min, abs(fmarkers(1)-port.f))]; +end + minind = nthargout(2, @min, s11dB); handle1 = plot(s11(lowerind),['<','b']); handle2 = plot(s11(upperind),['>','b']); @@ -120,6 +130,7 @@ handle3 = plot(s11(minind),['*', 'b']); llegend = num2str(port.f(lowerind)(1)/1e6, ffmt); ulegend = num2str(port.f(upperind)(1)/1e6, ffmt); + if nnz(lowerind) > 1 for i= 2:nnz(lowerind) llegend = strjoin({llegend, num2str(port.f(lowerind)(i)/1e6, ffmt)}, ', '); @@ -142,4 +153,4 @@ if (nargout == 0) clear h; end -end \ No newline at end of file +end