% [gse] = gea2gse(gea) transformas from GEA(J2000) to GSE, or MEA to MSE
%
% Initial version: Magnus Billvik, Swedish Institute of Space Physics,
%Uppsala, June 2005
% Revised by: Niklas Edberg, Swedish Institute of Space Physics, Uppsala, Oct 2005

function [gse] = gea2gse(gea, rs_gea)

gse=ones(size(gea));    % declare the variabel before to speed up the loop!

longitude=atan2(rs_gea(2,:),rs_gea(1,:));   % angle between x-axis and the Sun

for i=1:length(gea)
    T=R(longitude(i));
    gse(:,i)=T*gea(:,i);
end