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

4 vues (au cours des 30 derniers jours)
Nariç Durmus
Nariç Durmus le 13 Avr 2017
Modifié(e) : Stephen23 le 13 Avr 2017
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 commentaire
Stephen23
Stephen23 le 13 Avr 2017
Modifié(e) : Stephen23 le 13 Avr 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:

Connectez-vous pour commenter.

Réponses (1)

KSSV
KSSV le 13 Avr 2017

Catégories

En savoir plus sur External Language Interfaces dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by