How to save a variable in the same mat.file each time a function runs?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
I have a matlab function which runs in combination with BCI2000. I want to save a variable each time the function re-runs to do the calculations for the BCI server (real-time monitoring).
I tried something like this:
pp = 1; %begin point
variab= [];
for i= 1:1000
np(i) = pp + size(out_signal(i),1)-1; %next point
variable_new = [out_signal]
variab = [variab variable_new];
%variable(i) = [pp,]; % X moet je nog even bedenken hoe dat zit met variabelen/cells etc.
%(pp:np,:) voor size(A,2)>1
pp = np +1;
end
save ('variable.mat','variab')
This does not work. How can I save the outcome signal each time the function runs?
1 Kommentar
Stephen23
am 13 Apr. 2017
Bearbeitet: Stephen23
am 13 Apr. 2017
The easiest way would be to use matfile. Then you can simply access the variable in the .mat file by using indexing.
Whatever you do, do NOT try to create numbered variables: creating or accessing numbered variables makes slow, buggy, and obfuscated code:
Antworten (1)
Siehe auch
Kategorien
Mehr zu Timing and presenting 2D and 3D stimuli 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!