Build a matrix from saved arrays with differents lengths
1 view (last 30 days)
Show older comments
Hi to all!
I'm working on a simulation program. Each time the programs ends a simulation it saves the data (an array sized of 1 row and multiple columns) to a single .mat file: 'rf_ln1.mat'
For each simulation array size can change.
So, now: How can I construct a matrix from this saved different sized arrays? Because I don't know the size of each saved line unless I load them.
For example: rf_ln1.mat, rf_ln2.mat... rf_ln129.mat M = [rf_ln1.mat rf_ln2.mat ... rf_ln129.mat];
1. Is there an easy way such as using a struc or cell or a function? 2. Any tips? Ideas? Has someone already done this?
I would do: load file save it into a struc or cell (o create a variable with the name) seach the biggest one create a zero matrix sized (1,biggestone) create for each array a new one with the max size of all arrays insert it in the zero matrix
Any ideas with no so much steps?
Thanks for your answers! :)
0 Comments
Accepted Answer
Walter Roberson
on 23 Jan 2012
You can use whos() with the -file option in order to find the matrix sizes without loading the files.
2 Comments
Walter Roberson
on 23 Jan 2012
http://www.mathworks.com/help/techdoc/ref/whos.html
s = whos('rfline_post', '-file', 'rf_data/rf_post_In1.mat');
s.size
More Answers (1)
See Also
Categories
Find more on Data Type Identification 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!