numVec = randi([0,99],1,10000);range0to24 = length(find(numVec>=0 & numVec<=24));range25to49 = length(find(numVec>=25 & numVec<=49));range50to74 = length(find(numVec>=50 & numVec<=74));range75to99 = length(find(numVec>=75 & numVec<=99));
This is what I want to change into using for-loop and conditionals with 'if' codes.
I did like
for Vector = randi ([0,99],1,10000)if Vector>=0 && Vector<=24 from0to24 = length (find (Vector>=0 & Vector<=24));elseif Vector>=25 && Vector<=49 from25to49 = length (find (Vector>=25 & Vector<=49));elseif Vector>=50 && Vector<=74 from50to74 = length (find (Vector>=50 & Vector<=74));elseif Vector>=75 && Vector<=99 from50to74 = length (find (Vector>=75 & Vector<=99));else endfprintf ('%f \n', Vector)end
But they did not work at all.
How can I change the first with for-loop and conditionals?
Best Answer