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 CenterFile Exchange 中查找有关 Simulation 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by