Interrupt handling can be done in MATLAB using events and listeners. Refer to the few links given below for the reference,
Also, please refer to the below simple example which can give you an idea about how you can implement events and listeners,
classdef Test < handle
prop = 0;
obj.prop = value;
disp('The value of prop is overflowing');
The class 'Test' has an event 'overflow' which gets triggered when 'obj.prop>5'. Function "notify" is used to trigger the event. Function 'testD' is used to print the given message. Next, we will add a listener to the above event so that whenever the prop is greater than 5, it will print the message from function "testD". Here is the way how you can trigger the listener function,
As you can see, function "addlistener" is used to create an event listener.Whenever prop is greater than 5, the callback function 'testD' will get executed.
You can implement your code using similar manner. Please make a note that only handle classes can define events and listeners.