2013-06-04 13:50:15 +00:00
|
|
|
function h = plotFFdB(nf2ff,varargin)
|
|
|
|
% h = plotFFdB(nf2ff,varargin)
|
|
|
|
%
|
|
|
|
% plot far field pattern in dBi
|
|
|
|
%
|
|
|
|
% input:
|
|
|
|
% nf2ff: output of CalcNF2FF
|
|
|
|
%
|
|
|
|
% variable input:
|
2013-06-05 14:23:38 +00:00
|
|
|
% 'freq_index': - use the given frequency index, see nf2ff.freq
|
2013-06-04 13:50:15 +00:00
|
|
|
% - default is 1
|
|
|
|
% 'xaxis': - 'phi' (default) or 'theta'
|
|
|
|
% 'param': - array positions of parametric plot
|
|
|
|
% - if xaxis='phi', theta is parameter, and vice versa
|
|
|
|
% - default is 1
|
|
|
|
%
|
|
|
|
% example:
|
2013-06-05 14:23:38 +00:00
|
|
|
% plotFFdB(nf2ff, 'freq_index', 2, ...
|
2013-06-04 13:50:15 +00:00
|
|
|
% 'xaxis', 'phi', 'param', [1 46 91])
|
|
|
|
%
|
|
|
|
% see examples/NF2FF/infDipol.m
|
|
|
|
%
|
2013-06-13 08:08:29 +00:00
|
|
|
% See also CalcNF2FF, plotFF3D, polarFF
|
2013-06-04 13:50:15 +00:00
|
|
|
%
|
|
|
|
% openEMS matlab interface
|
|
|
|
% -----------------------
|
|
|
|
% author: Thorsten Liebig, Stefan Mahr
|
|
|
|
|
|
|
|
% defaults
|
2013-06-05 14:23:38 +00:00
|
|
|
freq_index = 1;
|
2013-06-04 13:50:15 +00:00
|
|
|
xaxis = 'phi';
|
|
|
|
param = 1;
|
|
|
|
|
|
|
|
for n=1:2:numel(varargin)
|
2013-06-05 14:23:38 +00:00
|
|
|
if (strcmp(varargin{n},'freq_index')==1);
|
|
|
|
freq_index = varargin{n+1};
|
2013-06-04 13:50:15 +00:00
|
|
|
elseif (strcmp(varargin{n},'xaxis')==1);
|
|
|
|
xaxis = varargin{n+1};
|
|
|
|
elseif (strcmp(varargin{n},'param')==1);
|
|
|
|
param = varargin{n+1};
|
2013-06-13 08:08:29 +00:00
|
|
|
else
|
|
|
|
warning('openEMS:plotFFdB',['unknown argument key: ''' varargin{n} '''']);
|
2013-06-04 13:50:15 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-06-05 14:23:38 +00:00
|
|
|
D_log = nf2ff.E_norm{freq_index} / max(nf2ff.E_norm{freq_index}(:));
|
2013-10-08 18:36:07 +00:00
|
|
|
D_log = 20*log10(D_log) + 10*log10(nf2ff.Dmax(freq_index));
|
2013-06-04 13:50:15 +00:00
|
|
|
|
|
|
|
if (strcmp(xaxis,'theta')==1);
|
|
|
|
xax = nf2ff.theta;
|
|
|
|
yax = D_log(:,param);
|
|
|
|
parval = nf2ff.phi(param);
|
|
|
|
param = 'phi';
|
|
|
|
elseif (strcmp(xaxis,'phi')==1);
|
|
|
|
xax = nf2ff.phi;
|
|
|
|
yax = D_log(param,:);
|
|
|
|
parval = nf2ff.theta(param);
|
|
|
|
param = 'theta';
|
2013-06-13 08:08:29 +00:00
|
|
|
else
|
|
|
|
error('openEMS:plotFFdB','unknown parameter to ''xaxis''');
|
2013-06-04 13:50:15 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
%figure
|
|
|
|
h = plot( xax / pi * 180 , yax );
|
|
|
|
xlabel( sprintf('%s (deg)',xaxis ));
|
|
|
|
ylabel( 'directivity (dBi)');
|
|
|
|
|
2013-06-05 14:03:04 +00:00
|
|
|
createlegend = @(d)sprintf('%s = %3.1f',param,d / pi * 180);
|
2013-06-04 13:50:15 +00:00
|
|
|
legendtext = arrayfun(createlegend,parval,'UniformOutput',0);
|
|
|
|
legend( legendtext );
|
2013-06-05 14:23:38 +00:00
|
|
|
title( sprintf('far field pattern @ f = %e Hz',nf2ff.freq(freq_index)) );
|
2013-06-04 13:50:15 +00:00
|
|
|
grid on;
|
|
|
|
|
|
|
|
if (nargout == 0)
|
|
|
|
clear h;
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|