matlab: updates to far-field plot functions
Signed-off-by: Thorsten Liebig <Thorsten.Liebig@gmx.de>
This commit is contained in:
parent
5644d86836
commit
f286b88c67
@ -7,18 +7,20 @@ function h = plotFF3D(nf2ff,varargin)
|
|||||||
% nf2ff: output of CalcNF2FF
|
% nf2ff: output of CalcNF2FF
|
||||||
%
|
%
|
||||||
% variable input:
|
% variable input:
|
||||||
% 'cellelement': - use element from cell array
|
% 'freq_index': - use the given frequency index, see nf2ff.freq
|
||||||
% - default is 1
|
% - default is 1
|
||||||
% 'logscale': - if set, show farfield with logarithmic scale
|
% 'logscale': - if set, show farfield with logarithmic scale
|
||||||
% - set the dB value for point of origin
|
% - set the dB value for point of origin
|
||||||
% - values below will be clamped
|
% - values below will be clamped
|
||||||
|
% 'normalize': - true/false, normalize linear plot
|
||||||
|
% - default is false, log-plot is always normalized!
|
||||||
%
|
%
|
||||||
% example:
|
% example:
|
||||||
% plotFF3D(nf2ff, 'cellelement', 2, 'logscale', -20)
|
% plotFF3D(nf2ff, 'freq_index', 2, 'logscale', -20)
|
||||||
%
|
%
|
||||||
% see examples/NF2FF/infDipol.m
|
% see examples/antennas/infDipol.m
|
||||||
%
|
%
|
||||||
% See also CalcNF2FF
|
% See also CalcNF2FF, plotFFdB
|
||||||
%
|
%
|
||||||
% openEMS matlab interface
|
% openEMS matlab interface
|
||||||
% -----------------------
|
% -----------------------
|
||||||
@ -26,40 +28,52 @@ function h = plotFF3D(nf2ff,varargin)
|
|||||||
|
|
||||||
% defaults
|
% defaults
|
||||||
logscale = [];
|
logscale = [];
|
||||||
cellelement = 1;
|
freq_index = 1;
|
||||||
|
normalize = 0;
|
||||||
|
|
||||||
for n=1:2:numel(varargin)
|
for n=1:2:numel(varargin)
|
||||||
if (strcmp(varargin{n},'logscale')==1);
|
if (strcmp(varargin{n},'logscale')==1);
|
||||||
logscale = varargin{n+1};
|
logscale = varargin{n+1};
|
||||||
elseif (strcmp(varargin{n},'cellelement')==1);
|
elseif (strcmp(varargin{n},'freq_index')==1);
|
||||||
cellelement = varargin{n+1};
|
freq_index = varargin{n+1};
|
||||||
|
elseif (strcmp(varargin{n},'normalize')==1);
|
||||||
|
normalize = varargin{n+1};
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
E_far_normalized = nf2ff.E_norm{cellelement} / max(nf2ff.E_norm{cellelement}(:));
|
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;
|
||||||
|
|
||||||
if ~isempty(logscale)
|
if ~isempty(logscale)
|
||||||
E_far_normalized = 20*log10(E_far_normalized)/-logscale + 1;
|
E_far = 20*log10(E_far)/-logscale + 1;
|
||||||
ind = find ( E_far_normalized < 0 );
|
E_far = E_far .* ( E_far > 0 );
|
||||||
E_far_normalized(ind) = 0;
|
titletext = sprintf('electrical far field [dB] @ f = %e Hz',nf2ff.freq(freq_index));
|
||||||
titletext = sprintf('electrical far field [dB] @ f = %e Hz',nf2ff.freq(cellelement));
|
elseif (normalize==0)
|
||||||
|
titletext = sprintf('electrical far field [V/m] @ f = %e Hz',nf2ff.freq(freq_index));
|
||||||
else
|
else
|
||||||
titletext = sprintf('electrical far field [V/m] @ f = %e Hz',nf2ff.freq(cellelement));
|
titletext = sprintf('normalized electrical far field @ f = %e Hz',nf2ff.freq(freq_index));
|
||||||
end
|
end
|
||||||
|
|
||||||
[theta,phi] = ndgrid(nf2ff.theta,nf2ff.phi);
|
[theta,phi] = ndgrid(nf2ff.theta,nf2ff.phi);
|
||||||
x = E_far_normalized .* sin(theta) .* cos(phi);
|
x = E_far .* sin(theta) .* cos(phi);
|
||||||
y = E_far_normalized .* sin(theta) .* sin(phi);
|
y = E_far .* sin(theta) .* sin(phi);
|
||||||
z = E_far_normalized .* cos(theta);
|
z = E_far .* cos(theta);
|
||||||
%figure
|
%figure
|
||||||
h = surf( x,y,z, E_far_normalized );
|
h = surf( x,y,z, E_far );
|
||||||
set(h,'EdgeColor','none');
|
set(h,'EdgeColor','none');
|
||||||
axis equal
|
axis equal
|
||||||
|
axis off
|
||||||
|
if ~isempty(logscale)
|
||||||
|
colorbar('YTick', linspace(0,max(E_far(:)),9), ...
|
||||||
|
'YTickLabel',linspace(logscale, 10*log10(nf2ff.Dmax(freq_index)),9));
|
||||||
|
else
|
||||||
|
colorbar;
|
||||||
|
end
|
||||||
|
|
||||||
title( titletext );
|
title( titletext );
|
||||||
xlabel( 'x' );
|
|
||||||
ylabel( 'y' );
|
|
||||||
zlabel( 'z' );
|
|
||||||
|
|
||||||
if (nargout == 0)
|
if (nargout == 0)
|
||||||
clear h;
|
clear h;
|
||||||
|
@ -7,7 +7,7 @@ function h = plotFFdB(nf2ff,varargin)
|
|||||||
% nf2ff: output of CalcNF2FF
|
% nf2ff: output of CalcNF2FF
|
||||||
%
|
%
|
||||||
% variable input:
|
% variable input:
|
||||||
% 'cellelement': - use element from cell array
|
% 'freq_index': - use the given frequency index, see nf2ff.freq
|
||||||
% - default is 1
|
% - default is 1
|
||||||
% 'xaxis': - 'phi' (default) or 'theta'
|
% 'xaxis': - 'phi' (default) or 'theta'
|
||||||
% 'param': - array positions of parametric plot
|
% 'param': - array positions of parametric plot
|
||||||
@ -15,25 +15,25 @@ function h = plotFFdB(nf2ff,varargin)
|
|||||||
% - default is 1
|
% - default is 1
|
||||||
%
|
%
|
||||||
% example:
|
% example:
|
||||||
% plotFFdB(nf2ff, 'cellelement', 2, ...
|
% plotFFdB(nf2ff, 'freq_index', 2, ...
|
||||||
% 'xaxis', 'phi', 'param', [1 46 91])
|
% 'xaxis', 'phi', 'param', [1 46 91])
|
||||||
%
|
%
|
||||||
% see examples/NF2FF/infDipol.m
|
% see examples/NF2FF/infDipol.m
|
||||||
%
|
%
|
||||||
% See also CalcNF2FF
|
% See also CalcNF2FF, plotFF3D
|
||||||
%
|
%
|
||||||
% openEMS matlab interface
|
% openEMS matlab interface
|
||||||
% -----------------------
|
% -----------------------
|
||||||
% author: Thorsten Liebig, Stefan Mahr
|
% author: Thorsten Liebig, Stefan Mahr
|
||||||
|
|
||||||
% defaults
|
% defaults
|
||||||
cellelement = 1;
|
freq_index = 1;
|
||||||
xaxis = 'phi';
|
xaxis = 'phi';
|
||||||
param = 1;
|
param = 1;
|
||||||
|
|
||||||
for n=1:2:numel(varargin)
|
for n=1:2:numel(varargin)
|
||||||
if (strcmp(varargin{n},'cellelement')==1);
|
if (strcmp(varargin{n},'freq_index')==1);
|
||||||
cellelement = varargin{n+1};
|
freq_index = varargin{n+1};
|
||||||
elseif (strcmp(varargin{n},'xaxis')==1);
|
elseif (strcmp(varargin{n},'xaxis')==1);
|
||||||
xaxis = varargin{n+1};
|
xaxis = varargin{n+1};
|
||||||
elseif (strcmp(varargin{n},'param')==1);
|
elseif (strcmp(varargin{n},'param')==1);
|
||||||
@ -41,7 +41,7 @@ for n=1:2:numel(varargin)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
D_log = nf2ff.E_norm{cellelement} / max(nf2ff.E_norm{cellelement}(:));
|
D_log = nf2ff.E_norm{freq_index} / max(nf2ff.E_norm{freq_index}(:));
|
||||||
D_log = 20*log10(D_log) + 10*log10(nf2ff.Dmax);
|
D_log = 20*log10(D_log) + 10*log10(nf2ff.Dmax);
|
||||||
|
|
||||||
if (strcmp(xaxis,'theta')==1);
|
if (strcmp(xaxis,'theta')==1);
|
||||||
@ -64,7 +64,7 @@ ylabel( 'directivity (dBi)');
|
|||||||
createlegend = @(d)sprintf('%s = %3.1f',param,d / pi * 180);
|
createlegend = @(d)sprintf('%s = %3.1f',param,d / pi * 180);
|
||||||
legendtext = arrayfun(createlegend,parval,'UniformOutput',0);
|
legendtext = arrayfun(createlegend,parval,'UniformOutput',0);
|
||||||
legend( legendtext );
|
legend( legendtext );
|
||||||
title( sprintf('far field pattern @ f = %e Hz',nf2ff.freq(cellelement)) );
|
title( sprintf('far field pattern @ f = %e Hz',nf2ff.freq(freq_index)) );
|
||||||
grid on;
|
grid on;
|
||||||
|
|
||||||
if (nargout == 0)
|
if (nargout == 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user