How to save a variable in the same mat.file each time a function runs?

1 view (last 30 days)
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 Comment
Stephen23
Stephen23 on 13 Apr 2017
Edited: Stephen23 on 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:

Sign in to comment.

Answers (1)

KSSV
KSSV on 13 Apr 2017

Community Treasure Hunt

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

Start Hunting!