In app designer how do I make a button to save, that saves my data from the different uitables and editfields? And the then afterwards make a button that loads it back in?
Mostrar comentarios más antiguos
Hi
Im looking for a tutorial on how to make a save and load button. Where I first can save my data to a file, and then afterwards load it again. I have a UITable where I need to save the data, and some editfield where I also want to save them. Afterwards I want to be able to start the program and then load them in.
Please help me:
uisave()
Doesnt help me that much.
Best regards Mikkel
Respuesta aceptada
Más respuestas (1)
Cyril Torre
el 6 de Oct. de 2020
Editada: Cyril Torre
el 6 de Oct. de 2020
I think the solution from Selby is the best, but I am giving my solution which is an alternative, maybe not optimised but easy to do it.
My solution would be to save everything in csv file in a folder and then load them after that. I will present you an example of what I got to save data.
Here the code to open a file, saved in the folder data, and called apdData_5mm_20201006 (because the current date is 06/10/2020 and zposition is a global variable defined by another function. But It does not matter you put what you want.
global zposition
current_date = datestr(now,'yyyymmdd_HHMMSS');
filename = sprintf('data/apdData_%smm_%s.csv', zposition, current_date );
fileIDapd = fopen(filename,'w');
fheader = 'z_sample, det_1, det_2, coinc, Klyshko1, Klyshko2, data_per_pixel, temperature, texp';
fprintf(fileIDapd,'%s\n', fheader);
fclose(fileIDapd);
Then to write I use the following code:
dlmwrite(filename, [posdata(1,1), apd1(j), apd2(j), coins(j),coins02(j),coins20(j), ...
dpp, temperature, TimeExp], ...
'delimiter', ',','precision', 16,'-append')
Im writing data every row, and this code is in a loop, where 'j' is the index for the row. posdata, apd1, coins, etc are my variables that I want to write on every column. For example in the 5th column, called Klyshko1 (previous code), my code will write under this column the variable coins02(j) for the j^th row
I am doing this because I am measuring data and recording them in the same time with my Matlab app desinger. But you can easily adapt it without the measuring step and just save it.
Obviously it's not the optimised way to do it but it's very easy to do it.
To load data, you just need to read this excel sheet and give every value to each cells?
Categorías
Más información sobre Develop Apps Using App Designer en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!