load .mat files in loop
Show older comments
I want to load .mat files saved in a specific foldar and perform some operations on each one of them and then save the answer in an array.
- Load .mat files in sequence with file names
S_out_02-10-2024 16-55.mat; S_out_02-10-2024 16-56.mat;S_out_02-10-2024 16-57.mat;S_out_02-10-2024 16-58.mat;........
content of each file is 3x6 double matrix
2. Do some calculations on data received from each file.
3. Save the output from calculation into another .mat file with 1 column and rows as output of each calculations.
Please suggest an effcient matlab code for the same.
1 Comment
"Please suggest an effcient matlab code for the same."
I presume that those digits represent dates and that by "in sequence" you actually mean in chronological order. If the dates had been given in an ISO 8601 date format (i.e. largest to smallest units) then you could trivially SORT them into chronological order.
However, because the date units are all reversed (i.e. smallest to largest) you make this task much more difficult. You will have to do something like:
- use DIR and parse the filenames into some kind of date representation (e.g. DATETIME) and SORT that.
- build the filenames from lists of all known units that exist in the filenames.
- something else...
Either way it will be more effort compared to if the filenames had been more carefully defined. Better data design makes code simpler, more robust, and much more efficient.
Accepted Answer
More Answers (0)
Categories
Find more on File Operations 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!