Save many vectors in one file

19 ビュー (過去 30 日間)
upt0zer0
upt0zer0 2012 年 12 月 6 日
Hi
I want to do the following:
(1) I get a lot of vectors, size [80,1] (2) This vectors should saved in a file or a workspace variable (3) but it shouldn't save [80,1],[80,1],[80,1],... it should save all as one big vektor with all elements in a row...
how can i do this?
Thx for any help.
  1 件のコメント
upt0zer0
upt0zer0 2012 年 12 月 6 日
ok, i know what you mean. the problem is, that I want to use it in an Simulink S-Function. So with every step there is a vector with dimensions [80,1]. When the first vector come, it should saved in a variable oder file. Then next step the next vector should be written in the same variable or file. But not vector after vector ... i want it as one big vector.
alternative, this would be even better: block or function to buffer 10 vectors of size [80,1] to one vector of size {800,1]

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

回答 (2 件)

Thomas
Thomas 2012 年 12 月 6 日
編集済み: Thomas 2012 年 12 月 6 日
a=rand(10,1); % first vector
b=rand(10,1); % second vector
c=rand(10,1); % third vector
out=[a b c] % combined matrix of above vectors
savename='test.mat';
save(savename,'out') % save the combined vector out in test.mat

Jan
Jan 2012 年 12 月 6 日
"I get a lot of vectors" does not reveal, how these vectors are stored. If you store them in the columns of a [80 x n] matrix, the question is solved already. If you store them in a {1 x n} cell, simply run:
M = cat(1, C{:});
If you store them in another format, please explain this, because we cannot guess such details.

カテゴリ

Help Center および File ExchangeSimulation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by