fileID = fopen('VD_data\bevly_skidpad.txt', 'r');
knots_to_m_per_s=0.514444444444444;
line=1;
hrp=1;
rmc=1;
while line~=-1
line = fgets(fileID);
    if(line~=-1)
        switch line(1:5)
            case '$PSSN'
                % message,message,time(hr:min:sec),date,heading(deg),roll(deg),pitch(deg)
                % sig_h,sig_r,sig_p,#of SVs, 2 others, checksum
                data = textscan(line, '%s %s %9c %s %f %f %f %f %f %f %f %f %f %s' ,'delimiter', ',', 'EmptyValue', -Inf);
                time_str=data{3};
                time_hr=str2num(time_str(1:2));
                time_min=str2num(time_str(3:4));
                time_sec=str2num(time_str(5:length(time_str)));
                time=time_min*60+time_sec;   % removing the hour!!! (+str2num(time_str(1:2)*3600)
                hrp_data(hrp,:)=[time data{5} data{6} data{7}];
                %hrp_data=[time heading(deg) roll(deg) pitch(deg)]
                hrp=hrp+1;
            case '$GPRM' % RMC Message
                % message,time,valid (=A), lat, N, long, W, speed(knots->m/s), course (deg) 
                % date, 2 others, checksum
                data = textscan(line, '%s %9c %s %f %s %f %s %f %f %s %f %s %s' ,'delimiter', ',', 'EmptyValue', -Inf);
                time_str=data{2};
                time_hr=str2num(time_str(1:2));
                time_min=str2num(time_str(3:4));
                time_sec=str2num(time_str(5:length(time_str)));
                time=time_min*60+time_sec;   % removing the hour!!! (+str2num(time_str(1:2)*3600)
                rmc_data(rmc,:)=[time data{4} data{6} data{8}*knots_to_m_per_s data{9}];
                %rmc_data=[time latitude longitude speed(m/s) couse(deg)]
                DATE=data{10};
                rmc=rmc+1;
        end
    end
end

 ST = fclose(fileID);
