mercredi 12 juin 2019

Hierarchy between and / or in an if statement

I have a file called data, within which there is a part Data.ensemble of which the first few lines look as following:

                Year Month Day Hour Min Temp
0   1635    1   2009    12  10  22  36  16.28
0   1635    2   2009    12  10  22  37  17.25
0   1635    3   2009    12  10  22  38  16.97
0   1635    4   2009    12  10  22  39  16.69
0   1635    5   2009    12  10  22  40  17.42

I want to extract the temperature in december on minute 0, 20, 30 and 40 every hour. I have trouble coding this. This is what I am trying:

Month = 12;
Minute=[0 20 30 40];

if Data.ensemble(:,5) == Month & (Data.ensemble(:,8) == (Minute(1)|Minute(2)|Minute(3)|Minute(4)))
Temperature(i) = Data.ensemble(:,10)
end

This doesn't seem to create Temperature, and I expect it's just gonna copy the entire colomn, not just the temperature for the correct minutes. Moreover, I am not quite sure the brackets really use the right hierarchy between and / or. It has to always be december(12) and on of the minutes (0 or 20 or 30 or 40).

Aucun commentaire:

Enregistrer un commentaire