How to save streaming data to Matlab workspace

1 回表示 (過去 30 日間)
want2know
want2know 2015 年 12 月 18 日
コメント済み: Renato Agurto 2015 年 12 月 18 日
Hi,
I am trying to save real-time streaming data obtained from hardware to Matlab workspace, I use the following command: My issue is, it only saved the last set of data, but not all data.
To save all variables from the workspace in binary MAT-file, test.mat, type
save test.mat
When I tried with this
save('test.mat','-append'); ,
it makes my program halt, so I would like to know what is the correct way to achieve this?
Thank you.
  2 件のコメント
Renato Agurto
Renato Agurto 2015 年 12 月 18 日
Hi. Do you get an error message? Do the saved variables have the same name? maybe they are constantly overwritten
want2know
want2know 2015 年 12 月 18 日
編集済み: want2know 2015 年 12 月 18 日
Thank you, yes you are right that they have same name and they are constantly overwritten, i did not get error message, I still get the file saved but i noticed that it only showed the latest set of data, what should I do to avoid this? I want it to save every set at each time step

サインインしてコメントする。

回答 (1 件)

Renato Agurto
Renato Agurto 2015 年 12 月 18 日
編集済み: Renato Agurto 2015 年 12 月 18 日
Hi, I don't have experience in real-time streaming but I would try to have a counter (t = 1:100) and save the variable(s) in a cell. For example your variables are var1, var2,... var5 and they are overwritten every second.
Here will all data be stored in a big cell myVar
myVar{t} = {var1, var2, var3, var4, var5};
or append every new variable. Here you get 5 "big" variables: v1,v2,v3,v4 & v5
%initialize
v1 = [];
v2 = [];
v3 = [];
v4 = [];
v5 = [];
And at every second append the data:
v1 = [v1, var1];
v2 = [v2, var2];
...
  2 件のコメント
want2know
want2know 2015 年 12 月 18 日
Thank you, do you mind to explain further as I don't get it, sorry..I do not want to overwrite variables, for example, I have five variables in the beginning of my test, I will still have only five variables in the end of my test, but I want to save each value of all five variables from t=1 to t=100 seconds, so I will have 100 sets of five variables (presuming one set data is saved every second)
Renato Agurto
Renato Agurto 2015 年 12 月 18 日
Hi. I tried to explain it better (see my edited answer).

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeWorkspace Variables and MAT Files についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by