Question

I have created a GUI, using GUIDE. I have added pushbuttons which perform a task. The start button, plots a graph and plays a wavefile that I have assigned to it. in the start button I have added as well a 'tic'.

on the other side of the GUI is have another button, the save button. The function of that button is to save to a vector the exact time that I push the button. The code that I have used saves only the last instance, while I want to be able to see all of the elements of that vector.

  handles.counter.push(handles.count + 1)
  handles.sfront(size(handles.counter)) = toc

Is there a way to save all of the instances to the sfront vector?

Thank you in advance!

Was it helpful?

Solution

You have to store your handles every time before the end of callback function.

Use GUIDATA:

guidata(hObject,handles)

OTHER TIPS

To add a new element to the end of a vector use:

handles.sfront(end+1) = toc;

Then call guidata(hObject,handles) to store the updated version of handles.

I can't recreate your entire GUI here, but here's an example of storing multiple toc outputs in a vector. Takes about 10 seconds to run:

tic
tocList = [];
for i = 1:5
    tocList(end+1) = toc;
    pause(2)
end
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top