function [B]=cylsheet_B(r,rc,y0,j,stepanz)
%**************************************************************************
% CLUSTER project: Cluster Flight                  Autor: Christian Maszl * 
% Unit System = [SI]                  Mail: e0025754@student.tuwien.ac.at *
%**************************************************************************
%
% This subroutine calculate the B field vectors for every
% position. The middle axis of the current tube with infinite
% length ist the z-axis. The current points in the positive z-direction.

B=zeros(10*stepanz,3);

for i=1:(10*stepanz)+1
% Compute the distance to the middle-axes.
abstand= sqrt(r(i,1)^2+r(i,2)^2);
% Compute the angle with respect to the x-axis.
phi    = acos(r(i,1)/abstand);
    if (abstand<=rc)
       % Innen
       Bl    =(y0/2)*j*abstand*1e9;
       B(i,1)=Bl*cos(phi+pi/2);
       B(i,2)=Bl*sin(phi+pi/2);
    elseif (abstand>rc)
       % Aussen
       Bl    =(y0/2)*j*rc^2/abstand*1e9;
       B(i,1)=Bl*cos(phi+pi/2);
       B(i,2)=Bl*sin(phi+pi/2);
    end
end




