Use relational and logical operators Do NOT use the find fun
Solution
1.b)
course = {\'Math\',\'History\',\'Physics\',\'Eng\',\'Chem\',\'Bio\'};
amygrades = [90 45 80 72 64 53];
 johngrades = [40 45 85 70 53 77];
for i=1:length(amygrades)
 elm = amygrades(i);
 if elm >= 80
 disp(elm);
 disp(course(i));
 end;
 end;
90
Math
80 Physics
1.c
course = {\'Math\',\'History\',\'Physics\',\'Eng\',\'Chem\',\'Bio\'};
amygrades = [90 45 80 72 64 53];
 johngrades = [40 45 85 70 53 77];
for i=1:length(amygrades)
 for j=1:length(johngrades)
 elm = amygrades(i);
 elm1 = johngrades(j);
 if elm==elm1 & i==j
 disp(course(i));
 end;
 end
 end;
History
1.d
course = {\'Math\',\'History\',\'Physics\',\'Eng\',\'Chem\',\'Bio\'};
amygrades = [90 45 80 72 64 53];
 johngrades = [40 45 85 70 53 77];
 count=0;
 for i=1:length(amygrades)
 for j=1:length(johngrades)
 elm = amygrades(i);
 elm1 = johngrades(j);
 if elm>elm1 && i==j
 count=count+1;
 disp(elm);
 disp(elm1);
 disp(course(i));
 end;
 end
 end;
 disp(count);
90
40
Math
72
70
Eng
64
53
Chem
Problem 3:
3.a
course = {\'Math\',\'History\',\'Physics\',\'Eng\',\'Chem\',\'Bio\'};
amygrades = [90 45 80 72 64 53];
 johngrades = [40 45 85 70 53 77];
 count=0;
 for i=1:length(amygrades)
 
 elm = amygrades(i);
 
 if elm>45 && elm<72
 disp(elm);
 end;
 end;
64
53
3.b
course = {\'Math\',\'History\',\'Physics\',\'Eng\',\'Chem\',\'Bio\'};
amygrades = [90 45 80 72 64 53];
 johngrades = [40 45 85 70 53 77];
 count=0;
 for i=1:length(amygrades)
 
 elm = amygrades(i);
 
 if elm>65 && elm<80
 disp(elm);
 end;
 end;
72
3.c)
course = {\'Math\',\'History\',\'Physics\',\'Eng\',\'Chem\',\'Bio\'};
amygrades = [90 45 80 72 64 53];
 johngrades = [40 45 85 70 53 77];
 count=0;
 for i=1:length(amygrades)
 
 elm = amygrades(i);
 
 if !(elm>65 && elm<80)
 disp(elm);
 end;
 end;
90
45
80
64
53
3.d)
course = {\'Math\',\'History\',\'Physics\',\'Eng\',\'Chem\',\'Bio\'};
amygrades = [90 45 80 72 64 53];
 johngrades = [40 45 85 70 53 77];
 count=0;
 disp(\"Amy\'s course greater than 70\");
 for i=1:length(amygrades)
 
 elm = amygrades(i);
   
 if elm>70
 disp(course(i));
 end;
 end;
 disp(\"John\'s course greater than 70\");
 for i=1:length(johngrades)
 
 elm = johngrades(i);
   
 if elm>70
 disp(course(i));
 end;
 end;
}
Amy\'s course greater than 70
Math
Physics
Eng
John\'s course greater than 70
Physics
Bio
3.e)
course = {\'Math\',\'History\',\'Physics\',\'Eng\',\'Chem\',\'Bio\'};
amygrades = [90 45 80 72 64 53];
 johngrades = [40 45 85 70 53 77];
for i=1:length(amygrades)
 for j=1:length(johngrades)
 elm = amygrades(i);
 elm1 = johngrades(j);
 if (elm>70 && elm1<70 && i==j) || (elm<70 && elm1>70 && i==j)
 disp(course(i));
 end;
 end
 end;
Math
Bio
3.f)
course = {\'Math\',\'History\',\'Physics\',\'Eng\',\'Chem\',\'Bio\'};
amygrades = [90 45 80 72 64 53];
 johngrades = [40 45 85 70 53 77];
for i=1:length(amygrades)
 for j=1:length(johngrades)
 elm = amygrades(i);
 elm1 = johngrades(j);
 if (elm<70 && elm1<70 && i==j)
 disp(course(i));
 end;
 end
 end;
History
chem
Problem 2, i am not able to use find function.




