
SP = serial( 'COM4', ...
    'BaudRate',9600, ...
    'Parity','none', ...
    'StopBits',1, ...
    'ReadAsyncMode','manual',...
    'Terminator','CR/LF');
fopen(SP)
closeSP = onCleanup(@()fclose(SP));

readasync(SP);

done = -1;
while done < 0
    inString = fgets(SP);
    if strcmp(inString(1:6),  '$GPGGA');
        fprintf(1, '%s', inString);
        %done = 1;
    end
end
fclose(SP);