How to add rows into existing .mat file?
Show older comments
I'm running a function (1) that read images, and then send each image into another function (2). function (2) is cropping 2000 patches from each image, and saves them.
I want to save 1 row of data (5 parameters) in a matrix for each patch.
At first I tried to create a global matrix and add row for each patch, but it make my script to be very slow.
So now I'm trying to save a .mat file on the disk, and then append rows there (instead of saving the matrix on the Matlab memory).
For conclusion: I'm looking for a way to add rows to existing .mat file, and I need this way to be fast (I have 3 millions rows)
Thanks a lot!
Answers (1)
Azzi Abdelmalek
on 14 Jul 2016
Look at this example, you can save your matrix as matrices of 100000 rows each for example
str='a':'z'
for k=1:10
clear A;
A.(str(k))=rand(4)
save('file.mat','-struct','A','-append')
end
Categories
Find more on Resizing and Reshaping Matrices 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!