How can I count number of dates over 100 degree F?

1 回表示 (過去 30 日間)
Nuria Andreu
Nuria Andreu 2021 年 8 月 29 日
コメント済み: Nuria Andreu 2021 年 8 月 30 日
Hello! I have a dataset with daily maximum temperatures and daily minimum temperatures from the 1930s to 2020. I have one data file with the dates and another one with the corresponding temperatures. I want to create a loop (or anything that works) to know how many days are above 100F and how many days are below 32F. Any suggestions?
Thank you!!
  2 件のコメント
Wan Ji
Wan Ji 2021 年 8 月 29 日
Can you share your dataset form so as to write code for you
Nuria Andreu
Nuria Andreu 2021 年 8 月 29 日
Yes! I extracted the daily maximum temperatures and daily minimum temperatures from a bigger dataset.
Thank you!

サインインしてコメントする。

採用された回答

Wan Ji
Wan Ji 2021 年 8 月 29 日
編集済み: Wan Ji 2021 年 8 月 29 日
dates = readtable('your_dates_file');
% assume that your dates fie has only one column
temps = readtable('your_temperature_file');
% assume that your temperature file has two columns, one is minimum T(°F), the
% other is maximum T (°F)
minT = temps{:,1};
maxT = temps{:,2};
p = minT<32; % or <=
q = maxT>100; % or >=
dates_below_32 = dates(p,:)
dates_above_100 = dates(q,:);
num_of_days_below_32 = sum(p);
num_of_days_above_100 = sum(q);
  2 件のコメント
Wan Ji
Wan Ji 2021 年 8 月 29 日
If my code helped you, please give me an acceptance. I need your encouragement
Nuria Andreu
Nuria Andreu 2021 年 8 月 30 日
It worked! thank you!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by