Its possible, not using toc though.
The problem is this, once your code reaches the input function it freezes in that line and waits for keyboard interaction.
the next line of code is only run after input is returned so toc is not reached at all.
you can use a timer and then proggramatically type the enter key on the "keyboard" using JAVA
timeout.ExecutionMode = 'singleShot';
timeout.TimerFcn = @doTimeout;
s = input('type something:', 's');
function doTimeout(tmr, ea)
This small example shows how to stop the input function forcefully after 10 seconds using the trick I mentioned.
This could backfire though if the user starts typing then the timer fires and stops the user in the middle.