MATLAB: Counting the number of data in the csv file

.csv filefor loop

Hello MATLAB community
temps is a bunch of numbers ranging from 20 to 70 in a column. So what I am struggling to do is that I want to sum the number of data points that are below 32 (just the number of data points not the actual data, which are numbers ranging from 20 to 70, summed up). Below is my code and I just don't know how to continue.
temps = load('40819DecJanLancasterTemp.csv');
plot(temps)
xlabel('Dec2018 Jan2018 Dec2019 Jan2019')
ylabel('Temperature (F)')
title('Hourly Temperature')
for i = 1:length(temps)
if temps(i) <= 32
elseif temps(i) > 32
end
end

Best Answer

Try this
indexesBelow32 = temps < 32
countBelow32 = sum(indexesBelow32)
You could of course do it all in one shot:
countBelow32 = sum(temps < 32)
No for loop needed to do the count.
Related Question