You can use callbacks in MATLAB to use event based execution.
As you are working with the Serial Port, I would suggest you to start with Using Callbacks for Serial Port Communication.
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!