load several .mat Files in For-Loop for several dates with one condition.

2 views (last 30 days)
Suresh R
Suresh R on 28 Oct 2021
Commented: Suresh R on 29 Oct 2021
i have one mat file which contains 80 rows in 'yyyymmdd' format. i have another folder with 238 mat files with same 'yyyymmdd' as mat file names. i want to load contents from the folder mat file to the first mat file where the date from the folder is less than the date of the first mat file.
mat file which has 80 rows
........ up to
next i have folder of 238 .mat files with following names
.....up to
so i want output as 2 columns
column1(which has 80 rows) column2(contents from the below mentioned mat file)
19900102 19891231.mat
19900301 19900131.mat
the condition is if we look at second row date is 19900301 i need contents of 19900228.mat file not 19900131 or 19900328 likewise i need for all 80 rows.
Thanks in Advance!!!
Suresh R
Suresh R on 29 Oct 2021
this is the output required in excel - i have attached photo with output required in excel.
as you can see in this photo the column values in A is the first mat file which contains 80 dates.
in b column it is the matfile name which contains values which are in columns C,D,E. this Mat file has size of 1500 X 3 values.
Likewise we have 238 matfiles for B column. we not need to print every matfile in B column.
we need to find the immediate date before the date present in Column A. that is if you see column A has date as 20020102 we need to find date which date is immediate before this date and print those contents in excel. in this case for 20020201 the immediate date before is 20011231.mat this file. so we have to print the contents in this mat file to this date 20020201. Hope you understand.

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!