function s = wires(a,b,d,m)
% s = wires(a,b,d,m)
% models a set of linear wires or tubes
% a, b :  Matrices n*[ax ay az] and n*[bx by bz] of wire end coordinates
% d    :  Vector of n wire diameter in m  (default = 0.002 m).
%         If a scalar value is given all wires will have this diameter.
% m    :  Vector of n numbers of segments.
%         If a scalar value is given it will be applicated to all wires.
% s    :  resulting antenna structure 

% Author:  Klaus von der Heide, e-mail:  dj5hg@qsl.net

% Defaults
% ========
if nargin<4,  m = 7; end
if nargin<3,  d = 0.002; end

% Parameter Check
% ===============
[na,a3] = size(a);
[nb,b3] = size(b);
nd = length(d);
nm = length(m);
if na~=nb,  error('wires:  incompatible numbers of wires at a and b'); end
n = na;
if nd==1,  d = ones(1,n)*d; end
if nm==1,  m = ones(1,n)*m; end
if length(d)~=n | length(m)~=n
   error('wires:  incompatible numbers of wires at d, m');
end

% Basic elements
% ==============
for k=1:n
   w{k} = wire(a(k,:),b(k,:),d(k),m(k));
end

% Putting all together
% ====================
s = construct(w{:});
