Hi! I am trying to write an if else statement inside of a for loop in order to determine how many people surveyed had a specific response. I posted my code below. Every time I run it instead of generating the numbers, it generates my fprintf statement that amount of time. I am just really confused because I followed the template my professor gave and it just isn't working for me. Thank you,
y=load('Class19_survey.txt');ag=0;ne=0;dis=0;for k=1:length(y) if y(k)>=4 ag=ag+1; fprintf('\nThe number of people who agree is\n',ag) elseif y(k)==3 ne=ne+1 fprintf('\nThe number of neutral responses is\n',ne) else y(k)<=2 dis=dis+1 fprintf('\nThe number of disagree responses is\n', dis) end end
Best Answer