from Guide to Serial Port Interfacing by Nitin Skandan
This article will give a detailed description of serial port interfacing in MATLAB.

readeventscript.m
%   /***********************************************************************
% 
% * Company: TATA ELXSI LIMITED
% 
% * File Name: readeventscript.m
% 
% * Author : Nitin S
% 
% * Version : 0.0.1
% 
% * Description: This script performs read operation on an event
% 
% * Date :10/08/2005
% 
% * Customer Bug No./ CMF No. : NA
% 
% * Brief description of the fix/enhancement: NA
% 
% ***********************************************************************/
serobj ;                                                                                   % Serial object after connection established
serobj.ReadAsyncMode = 'manual' ;                                        %  Lets do it in asynchronous mode

serobj.Timeout = 5 ;
serobj.Timerperiod = 1 ;                
serobj.Timerfcn = {'servicetimer'} ;                                         % This function will be called every 1 sec as given by Timerperiod
global count  ;
count = 0 ;

while 1
    readasync(serobj);                                                              % Read till terminator
    while(serobj.TransferStatus ~= 'idle')        
    end
    fscanf(serobj)
    if(count > 20)
        break;
    end    
end

fclose(serobj) ;
delete(serobj) ;
clear;

Contact us at files@mathworks.com