I can't think of a straightforward solution, since MATLAB doesn't allow you to programmatically trigger a Ctrl+C ; nor can you catch a Ctrl+C keypress using try..catch in your code.
Here's one way to do it, by periodically checking the value of a UI toggle - which says Continue/Interrupt.
fig = uifigure('Position',[680 678 398 271]);
bg = uibuttongroup(fig,'Position',[137 113 123 85]);
tb1 = uitogglebutton(bg,'Position',[10 50 100 22]);
tb2 = uitogglebutton(bg,'Position',[10 28 100 22]);
tb1.Text = 'Continue';
tb2.Text = 'Interrupt';
lastTocValue = 0;
if(toc > lastTocValue+10)
If you run this, a UI dialog should pop up when the function starts. If you want the function to be interrupted, just set the toggle in the window to 'Interrupt' and when execution gets to the if-condition shown above, the function would return if 10 seconds have passed.
If embedding extra code into the function is too clunky, you may try using a timer object to routinely check the value as well every 'T' seconds.
Hope it helps!