How to save data in a GUI button callback?

1 Ansicht (letzte 30 Tage)
Ibro Tutic
Ibro Tutic am 7 Jun. 2017
Bearbeitet: Jan am 8 Jun. 2017
I have a function that I run for plotting certain data called englishplot whose output is a structure containing relevant data. I assign this structure to handles.data within the button callback. Now when I want to add something to handles.data, it is always overwritten with the new data, instead of having the new structure added to the old one.
In my button callback I have
handles.j=1;
handles.data=englishplot(handles.graphs,handles.test,handles.j,handles.DLG)
handles.j=handles.j+1;
Where handles.graphs is a user selected graph or graphs to graph, handles.test is the test number, handles.DLG is the raw data to pull from and handles.j is an index to keep track of any new plots that are added. This works for the first structure, and the output from handles.data = Plot1 (a 1x1 structure). Now what I want is that if the button is pressed again, handles.j = 2, and then handles.data would include Plot1 AND Plot2.
Any ideas?

Akzeptierte Antwort

Jan
Jan am 7 Jun. 2017
Bearbeitet: Jan am 8 Jun. 2017
Initialize handles.j = 0 in the OpeningFcn. Then:
handles.j = handles.j + 1;
handles.data(handles.j) = englishplot(handles.graphs,handles.test,handles.j,handles.DLG)

Weitere Antworten (0)

Kategorien

Mehr zu Startup and Shutdown finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by