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

1 次查看(过去 30 天)
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 个评论
Stephen23
Stephen23 2017-4-13
编辑:Stephen23 2017-4-13
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:

请先登录,再进行评论。

回答(1 个)

KSSV
KSSV 2017-4-13

类别

Help CenterFile Exchange 中查找有关 Timing and presenting 2D and 3D stimuli 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by