Azzera filtri
Azzera filtri

save the output data of GUI

9 visualizzazioni (ultimi 30 giorni)
RJS
RJS il 29 Nov 2021
Commentato: Jan il 1 Dic 2021
I am testing the number of data file in my GUI, Now I want to store the output data of each file . My question is how can i incrementally save the output on a list.
Kp = getappdata(0,'Kp')
Kr = getappdata(0,'Kr')
if exist('myData.mat','file')
S=load('myData.mat');
gain=S.gain;
else
gain = struct('Kp','Kr');
gain.Kp = Kp;
gain.Kr = Kr;
end
save('myData.mat','gain');
it just stores the first data,,,please help

Risposta accettata

Jan
Jan il 29 Nov 2021
Modificato: Jan il 29 Nov 2021
Kp = getappdata(0, 'Kp');
Kr = getappdata(0, 'Kr');
if isfile('myData.mat') % older: exist('myData.mat','file')
S = load('myData.mat');
gain = S.gain;
gain.Kp(end + 1) = Kp;
gain.Kr(end + 1) = Kr;
else
gain.Kp = Kp;
gain.Kr = Kr;
end
save('myData.mat', 'gain');
Hints:
  • Store the data inside the GUI instead of the root object, where they are shared with all other applications, which write to the root object. This has the same drawbacks as using global variables.
  • Do not rely on the current folder. A user can change the current folder, or a callback of the GUI. So add a specific folder to the file, e.g.
myPath = fileparts(mfilename('fullpath'));
file = fullfile(myPath, 'myDFata.mat');
if isfile(file)
S = load(file);
... etc.
end
Using absolute path names is safer.
  4 Commenti
RJS
RJS il 1 Dic 2021
I mean can I save this variable in excel sheet?
Jan
Jan il 1 Dic 2021
Yes, of course.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Workspace Variables and MAT-Files in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by