function Hpc = CorrectMagneticField(Hp, Ivert, Ihoriz, probesInfo) % CorrectMagneticField - Corrects the poloidal magnetic fields taking into % account the field created by the horizontal, % vertical and primary magnetic fields. % % Hpc = CorrectMagneticField(Hp, Ivert, Ihoriz, Iprim, probesInfo) % % Inputs: % Hp - Poloidal magnetic field % Ivert - Vertical field winding current % Ihoriz - Horizontal field winding current % probesInfo - Magnetic probes information structure % % Outputs: % Hpc - Corrected poloidal magnetic field %% Initializations ivertHp = zeros(size(Hp)); ihorizHp = zeros(size(Hp)); %% Normalized magnetic fields ivertNormHp = -hpol_espira(probesInfo, 0.58, 0.07) - hpol_espira(probesInfo, 0.58, -0.07) + hpol_espira(probesInfo, 0.35, 0.07) + hpol_espira(probesInfo, 0.35, -0.07); ihorizNormHp = +hpol_espira(probesInfo, 0.58, 0.07) - hpol_espira(probesInfo, 0.58, -0.07); %% Calculate contributions for i = 1:size(Hp, 1) %% Calculate Ivert contribution ivertHp(i,:) = 5 * Ivert(i) * ivertNormHp; %% Calculate Ihoriz contribution ihorizHp(i,:) = 3 * Ihoriz(i) * ihorizNormHp; end %% Correct magnetic field Hpc = Hp - ivertHp - ihorizHp;