Saving output from MATLAB GUI as a list.

Lets say each time i run the GUI it gives out a output A.then later I will add a second set of data and get a second output for A, third.. and a fourth.. so on and so forth. My question is how can i incrementally save the output on a list. I understand i might need to create a Zero array but when i run the GUI a second time with a new data set how can i make sure the output A is saved on the second element instead of overwriting the first output element. I hope you understand my question! Thank you :)

 Accepted Answer

Isura1992 - I think that you will want to save the set of data to a mat file and then on subsequent uses of your GUI, append data to that file...assuming that the data you are appending is of the same dimension. Let's suppose that you have your set of data A that you wish to say (presumably from within a callback). We would look for the mat file to load
matFileToLoad = 'myData.mat';
if exist(matFileToLoad,'file')
% file exists so load it and append the new A to it
fileData = load(matFileToLoad);
A = [fileData.A ; A];
end
save(matFileToLoad,'A');
Note that when we load the data from the file, fileData is a struct whose field is the name of the variable that we saved to the mat file. In this case, the field will be named A. So we access this field and vertically concatenate the new A to it and save the updated A to file.
Try the above and see what happens!

2 Comments

Thank you so much for taking the time to answer the question! Its works!!!!
I want to load the last value only from mydata.mat

Sign in to comment.

More Answers (0)

Categories

Community Treasure Hunt

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

Start Hunting!