function print_lph_XYZ( time, var_a, var_b, var_c, type )

if strcmpi(type,'llh')
    fid = fopen('ATStraj_llh_rad.txt','w');
    
    % skip the first and last as they are NaN
    for(i=1:length(time))
        if ( (isnan(time(i))==0)&(isnan(var_a(i))==0) )
            fprintf(fid,'%10.2f %12.10f %12.10f %10.3f\r\n', time(i), var_b(i), var_a(i), var_c(i));
        end
    end
    fclose(fid);
elseif strcmpi(type,'xyz')
    fid = fopen('ATStraj_XYZ.txt','w');
    
    % skip the first and last as they are NaN
    for(i=1:length(time))
        if ( (isnan(time(i))==0)&(isnan(var_a(i))==0) )
            fprintf(fid,'%10.2f %15.3f %15.3f %15.3f\r\n', time(i), var_a(i), var_b(i), var_c(i));
        end
    end
    fclose(fid);
elseif strcmpi(type,'xyzvel')
    fid = fopen('ATStraj_XYZvel.txt','w');    
    for(i=1:length(time))
        if ( (isnan(time(i))==0)&(isnan(var_a(i))==0) )
            fprintf(fid,'%10.2f %2.3f %2.3f %2.3f\r\n', time(i), var_a(i), var_b(i), var_c(i));
        end
    end
    fclose(fid);
elseif strcmpi(type,'llhvel')
    fid = fopen('ATStraj_LLHvel.txt','w');
    for(i=1:length(time))
        if ( (isnan(time(i))==0)&(isnan(var_a(i))==0) )
            fprintf(fid,'%10.2f %.15f %.15f %2.3f\r\n', time(i), var_b(i), var_a(i), var_c(i));
        end
    end
    fclose(fid);
elseif strcmpi(type,'nedvel')
    fid = fopen('ATStraj_NEDvel.txt','w');
    for(i=1:length(time))
        if ( (isnan(time(i))==0)&(isnan(var_a(i))==0) )
            fprintf(fid,'%10.2f %2.3f %2.3f %2.3f\r\n', time(i), var_a(i), var_b(i), var_c(i));
        end
    end
    fclose(fid);
end    

return;
