Save many vectors in one file

19 views (last 30 days)
upt0zer0
upt0zer0 on 6 Dec 2012
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 Comment
upt0zer0
upt0zer0 on 6 Dec 2012
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]

Sign in to comment.

Answers (2)

Thomas
Thomas on 6 Dec 2012
Edited: Thomas on 6 Dec 2012
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 on 6 Dec 2012
"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.

Categories

Find more on Simulation in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!