Hello. I'm fairly new to using GUIDE so thank you for your patience. I have gui with "Record On/Off" pushbutton which serves to start and stop a timer object. The default setting is therefore infinite in that the timer object will run until the stop button is pressed. Additionally, when pushbutton is pressed to stop the timer, several other processes are performed (e.g., changing the color of the button, preprocessing and saving the data generated during the timer object etc.).
However, I have an optional setting in which the user can specify a custom duration. When a duration is specified, the 'TasksToExecute' is set thus stopping the timer automatically after the duration has elapsed.
The issue is, that because the Recording pushbutton executes several operations in addition to stopping the timer, I need to trigger the button press via the timer's StopFcn. Being a novice with guide, I'm confused about executing callbacks within another call back. I've pasted the relevant sections of code below:
function Record_Callback(hObject, eventdata, handles)
RecordStatus = get(hObject,'Value');
if RecordStatus == 1
set(hObject, 'string', 'STOP Recording');
set(hObject, 'ForegroundColor', 'black');
Duration_MS = handles.dur * (60 * handles.hertz);
if Duration_MS > 0;
NumExecutions = [handles.dur * 60] / get(handles.tmr, 'Period');
set(handles.tmr, 'TasksToExecute', NumExecutions);
elseif RecordStatus == 0
timeElapsed = toc;
Here is the StopFcn which I'd like to figure out how to simulate a button press (i.e. stop recording).
disp(['recording should have stopped at ' toc]);