function [R Z] = CalculatePlasmaPosition_SA(magneticData, bobines) %% Plasma position - simple algorithm R = zeros(size(magneticData, 1), 1); Z = zeros(size(magneticData, 1), 1); magneticDataSum = sum(magneticData, 2); Rb = repmat(bobines.R, size(magneticData, 1), 1); Zb = repmat(bobines.Z, size(magneticData, 1), 1); productMagneticR = magneticData .* Rb; productMagneticZ = magneticData .* Zb; sumProductMagneticR = sum(productMagneticR, 2); sumProductMagneticZ = sum(productMagneticZ, 2); for i = 1:size(magneticData, 1) %if magneticDataSum(i) < 1e-2 % R(i) = 0; % Z(i) = 0; %else %R(i) = (sumProductMagneticR(i) / magneticDataSum(i) + bobines.rb^2 / (4*bobines.RM) - bobines.RM); R(i) = 2*(sumProductMagneticR(i) / magneticDataSum(i) - bobines.RM) + 0.04 - 0.006; Z(i) = 2*(sumProductMagneticZ(i) / magneticDataSum(i));%; + 0.004*sign(magneticDataSum(i))); if R(i) < -0.085 R(i) = -0.085; end if R(i) > 0.085 R(i) = 0.085; end if Z(i) < -0.085 Z(i) = -0.085; end if Z(i) > 0.085 Z(i) = 0.085; end %end end % figure; % plot(R, 'r'); % hold on; % plot(Z, 'b');