2013-06-04 13:50:15 +00:00
|
|
|
function h = plotFF3D(nf2ff,varargin)
|
|
|
|
% h = plotFF3D(nf2ff,varargin)
|
|
|
|
%
|
|
|
|
% plot normalized 3D far field pattern
|
|
|
|
%
|
|
|
|
% 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
|
|
|
|
% 'logscale': - if set, show farfield with logarithmic scale
|
|
|
|
% - set the dB value for point of origin
|
|
|
|
% - values below will be clamped
|
2013-06-05 14:23:38 +00:00
|
|
|
% 'normalize': - true/false, normalize linear plot
|
|
|
|
% - default is false, log-plot is always normalized!
|
2013-06-04 13:50:15 +00:00
|
|
|
%
|
|
|
|
% example:
|
2013-06-05 14:23:38 +00:00
|
|
|
% plotFF3D(nf2ff, 'freq_index', 2, 'logscale', -20)
|
2013-06-04 13:50:15 +00:00
|
|
|
%
|
2013-06-05 14:23:38 +00:00
|
|
|
% see examples/antennas/infDipol.m
|
2013-06-04 13:50:15 +00:00
|
|
|
%
|
2013-06-13 08:08:29 +00:00
|
|
|
% See also CalcNF2FF, plotFFdB, polarFF
|
2013-06-04 13:50:15 +00:00
|
|
|
%
|
|
|
|
% openEMS matlab interface
|
|
|
|
% -----------------------
|
|
|
|
% author: Thorsten Liebig, Stefan Mahr
|
|
|
|
|
|
|
|
% defaults
|
|
|
|
logscale = [];
|
2013-06-05 14:23:38 +00:00
|
|
|
freq_index = 1;
|
|
|
|
normalize = 0;
|
2013-06-04 13:50:15 +00:00
|
|
|
|
|
|
|
for n=1:2:numel(varargin)
|
|
|
|
if (strcmp(varargin{n},'logscale')==1);
|
|
|
|
logscale = varargin{n+1};
|
2013-06-05 14:23:38 +00:00
|
|
|
elseif (strcmp(varargin{n},'freq_index')==1);
|
|
|
|
freq_index = varargin{n+1};
|
|
|
|
elseif (strcmp(varargin{n},'normalize')==1);
|
|
|
|
normalize = varargin{n+1};
|
2013-06-13 08:08:29 +00:00
|
|
|
else
|
|
|
|
warning('openEMS:plotFF3D',['unknown argument key: ''' varargin{n} '''']);
|
2013-06-04 13:50:15 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-06-05 14:23:38 +00:00
|
|
|
if ((normalize~=0) || ~isempty(logscale))
|
|
|
|
E_far = nf2ff.E_norm{freq_index} / max(nf2ff.E_norm{freq_index}(:));
|
|
|
|
else
|
|
|
|
E_far = nf2ff.E_norm{freq_index};
|
|
|
|
end;
|
2013-06-04 13:50:15 +00:00
|
|
|
|
|
|
|
if ~isempty(logscale)
|
2013-06-05 14:23:38 +00:00
|
|
|
E_far = 20*log10(E_far)/-logscale + 1;
|
|
|
|
E_far = E_far .* ( E_far > 0 );
|
|
|
|
titletext = sprintf('electrical far field [dB] @ f = %e Hz',nf2ff.freq(freq_index));
|
|
|
|
elseif (normalize==0)
|
|
|
|
titletext = sprintf('electrical far field [V/m] @ f = %e Hz',nf2ff.freq(freq_index));
|
2013-06-04 13:50:15 +00:00
|
|
|
else
|
2013-06-05 14:23:38 +00:00
|
|
|
titletext = sprintf('normalized electrical far field @ f = %e Hz',nf2ff.freq(freq_index));
|
2013-06-04 13:50:15 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
[theta,phi] = ndgrid(nf2ff.theta,nf2ff.phi);
|
2013-06-05 14:23:38 +00:00
|
|
|
x = E_far .* sin(theta) .* cos(phi);
|
|
|
|
y = E_far .* sin(theta) .* sin(phi);
|
|
|
|
z = E_far .* cos(theta);
|
2013-06-04 13:50:15 +00:00
|
|
|
%figure
|
2013-06-05 14:23:38 +00:00
|
|
|
h = surf( x,y,z, E_far );
|
2013-06-04 13:50:15 +00:00
|
|
|
set(h,'EdgeColor','none');
|
|
|
|
axis equal
|
2013-06-05 14:23:38 +00:00
|
|
|
axis off
|
|
|
|
if ~isempty(logscale)
|
|
|
|
colorbar('YTick', linspace(0,max(E_far(:)),9), ...
|
2013-06-13 15:13:06 +00:00
|
|
|
'YTickLabel',num2str(linspace(logscale, 10*log10(nf2ff.Dmax(freq_index)),9)'));
|
2013-06-05 14:23:38 +00:00
|
|
|
else
|
|
|
|
colorbar;
|
|
|
|
end
|
2013-06-04 13:50:15 +00:00
|
|
|
|
|
|
|
title( titletext );
|
|
|
|
|
|
|
|
if (nargout == 0)
|
|
|
|
clear h;
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|