MATLAB: Using for loop for arrays

arraysMATLAB

I have an array that includes a list of temps, and I am trying to count the temps less than 75. This is the code I used –
clc;
clear;
close all;
count=0;
a = [45, 56, 66, 78, 54, 67, 56, 88, 95, 93, 23, 56, 78, 45, 67, 56, 34, 67, 87, 64, 94, 57, 61, 24]; %16 below 75
for i = 1 : length(a)
if i < 75
count = count+1;
end
end
disp(count)
Not sure what is wrong. I am not able to get the desired output. Any help?

Best Answer

Not sure what is wrong
You'll always going to get min(74, numel(a)) as a count, since you're comparing the index i instead of the value a(i) to 75.
Note that as usual in matlab, there's no need for a loop for this
count = nnz(A < 75)
%or
count = sum(A < 75)