Comparing date/time values in Matlab/ calling out date time values to use in code
Show older comments
Hi,
So I have to sets of data one represents wind speed, and the other represents radar rain data.
My wind data is imported from excel and consists of a column of dates and the the remaining colums are values of wind speeds for different stations at these date times.
The radar data is a hdf file that has been converetd into rain intensity in another function.
Each set of data is in time increments of 5 minutes beginning September 2020.
E.g. first 4 sets of data :
- '01-Sep-2020 00:00:00'
- '01-Sep-2020 00:05:00'
- '01-Sep-2020 00:10:00'
- '01-Sep-2020 00:15:00'
I have looking to add a line that will compare the date/time values of the wind data to the date/time values of the radar data for each time point.
When the code finds a match, it can then be used in two other functinos I have.
A suggested start is
for i = 1:length(WindDatetime)
if RadarDatetime == WindDatetime(i)
then the file of interest == i
else
i =i +1;
end
end
However, this is not working for me.
I will insert the last part of my code that turns the date time vectors into a table of numbers like so :
2020 9 1 0 0 0
2020 9 1 0 5 0
2020 9 1 0 10 0
windtime = windfive.date; % extracting the date column from excel sheet
idx = ismember(windtime,timestampDT); % show which data is missing
windtime(~idx);
Winddata = datevec(windtime); %turn wind time data into a vector
Radardata = datevec(timestampDT); % turn radar time data into a vector
Radardata(any(isnan(Radardata),2),:) =[]; % delete any 'NaN' values
Another very useful thing to me would be if anyone knows a simple way of calling out time data so that I can use it.
For example if I would like to view the data between
'08-Sep-2020 23:55:00' and '17-Sep-2020 17:45:00'
is there a way of doing this?
Thanks:)
Accepted Answer
More Answers (0)
Categories
Find more on Dates and Time 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!