Build a matrix from saved arrays with differents lengths
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Walter Roberson
2012-1-23
You can use whos() with the -file option in order to find the matrix sizes without loading the files.
2 个评论
Walter Roberson
2012-1-23
http://www.mathworks.com/help/techdoc/ref/whos.html
s = whos('rfline_post', '-file', 'rf_data/rf_post_In1.mat');
s.size
更多回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Type Identification 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!