Let's go through your function line by line.
fileID = fopen('exptable.txt','w');
Looks good to this point.
This previous line doesn't do what you think it does. MATLAB will run this code to create an anonymous function with body iwrite(), assign that anonymous function to ans, and display ans. [Calling that anonymous function will not call the iwrite local function, as that is not in scope.]
To have MATLAB call the function handle to the iwrite function that was set as the TimerFcn when this line of code was executed:
set(a, 'TimerFcn', @(~, ~) iwrite())
You don't use the timer object handle or the event data that the timer will pass into the TimerFcn inside that TimerFcn, so I just ignore them.
The rest of your code is fine, except that you leave the file open even after you stop the timer. You probably want to set the timer's StopFcn inside your start function and have it close the file when it is executed. Again, since the StopFcn doesn't need to do anything with the timer object or the event data, I use ~ to ignore what MATLAB passes into the StopFcn automatically.
a.StopFcn = @(~, ~) fclose(fileID);
I'd also return the timer from start, so that it's easy to stop.
Call this as: