Calculate if statement based on date
3 views (last 30 days)
Show older comments
Hello,
I have a spreadsheet. In column A, are the dates. In column E, I have the precipitation values.
I need to sum certain precipitation values (of Column E) together per date, based on Latitude and Longitude, columns F and G respectively. Then, I need to designate either S1, S2, ...
For instance, I need to calculate the sum of precipitation values for S12 for each date. S12 is based on the following Latitude and Longitude values:
40.6323 -74.1923
40.5935 -74.1066
40.5804, 74.175
40.561, -74.1322
40.5478, -74.2005
40.5284, -74.1577
40.5153, -74.226
If any one could help me with this, I would greatly appreciate it.
I've attached a spreadsheet that covers about 20 days, since my file was too big (its 3,650 days).
Thanks,
Candace
4 Comments
Answers (1)
Star Strider
on 28 May 2020
Try this:
T1 = readtable('Precip.Sample.xlsx');
TT1 = table2timetable(T1);
TTRP = retime(TT1(:,1:4), 'daily', 'sum');
TTRL = retime(TT1(:,5:6), 'daily', 'mean');
TTR = innerjoin(TTRP,TTRL)
producing:
TTR =
36×6 timetable
Date Precip (mm) PRECIP (in) Weights Final PRECIP Latitude Longitude
___________ ___________ ___________ _______ ____________ ________ _________
01-Jan-2010 846.6 33.331 55.27 23.292 40.671 -73.985
02-Jan-2010 184.5 7.2638 55.27 3.9852 40.671 -73.985
03-Jan-2010 65.8 2.5906 55.27 1.471 40.671 -73.985
04-Jan-2010 8.2 0.32283 55.27 0.23122 40.671 -73.985
05-Jan-2010 0 0 55.27 0 40.671 -73.985
06-Jan-2010 0 0 55.27 0 40.671 -73.985
07-Jan-2010 0 0 55.27 0 40.671 -73.985
08-Jan-2010 59.1 2.3268 55.27 1.6153 40.671 -73.985
... CONTINUED ...
.
See Also
Categories
Find more on Data Import and Analysis in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!