Hi Jomei,
The issue you're facing is due to reinitializing the 'Store_data' matrix as an empty matrix each time you press the button. This overwrites any previously stored data, leaving only the last entry.
To maintain the data across button presses using the base workspace, you can retrieve the existing 'Store_data' from the base workspace at the beginning of your callback function.
Here's how you can retrieve and update 'Store_data' correctly:
% Check if Store_data already exists in the base workspace
if evalin('base', 'exist(''Store_data'', ''var'')')
Store_data = evalin('base', 'Store_data');
else
Store_data = []; % Initialize if it doesn't exist
end
% code continue...
% In the end save the updated matrix back to the base workspace
assignin('base', 'Store_data', Store_data);
This approach ensures that 'Store_data' retains all previous entries and appends new data correctly each time the button is pressed.
I hope this helps!