How do I find how many days there are that have a temperature between 10 and 30

1 回表示 (過去 30 日間)
I need help finding how many days there are in a year that have a temperature between 10 and 30 from multiple spreadsheets. I have the spreadsheets coming from a folder using:
source_directory = 'C:\Users\thoma\OneDrive\Desktop\Project 1';
source_file = dir(fullfile(source_directory, '*.csv'));
TempLow = file_data(:, 1);
TempHigh = file_data(:, 2);
The TempHigh and TempLow only show 30 data points each when it should be 365 data points each.
TempLow = file_data(:, 1);
TempHigh = file_data(:, 2);
TempC = [TempLow, TempHigh];
Temp = input('Enter a temperature: ');
if Temp <= 10
disp('Too Low')
elseif Temp >= 30
disp('Too High')
else
disp('Comfortable'), disp(TempCDays)
end
(Calculate the total number of days with comfortable temperature (10-30 degrees Celsius) and show the result on the Command Window)

採用された回答

madhan ravi
madhan ravi 2020 年 6 月 20 日
Use &
  4 件のコメント
Thomas Portsmouth
Thomas Portsmouth 2020 年 6 月 20 日
編集済み: Thomas Portsmouth 2020 年 6 月 20 日
This results with an answer of 547 which is impossible because there is only 366 days. Am I entering this in right?
TempC = [MinTemp_Year MaxTemp_Year];
TempCDays = nnz((TempC >= 10) & (TempC <= 30));
Temp = input('Enter a temperature: ');
if Temp <= 10
disp('Too Low')
elseif Temp >= 30
disp('Too High')
else
disp('Comfortable'), disp(TempCDays)
end
Thomas Portsmouth
Thomas Portsmouth 2020 年 6 月 20 日
Nevermind, I just had to change the (TempC >=10) to (MinTemp_Year > 10) and vida versa for the next value. Thanks

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeProgramming についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by