Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This is a MATLAB problem: Problem 2. A script stores information on potential su

ID: 2266078 • Letter: T

Question

This is a MATLAB problem:

Problem 2. A script stores information on potential subjects for an experiment in a vector of structures called Subjects. For this particular experiment, the only subjects who are eligible are those whose height or weight is lower than the average height or average weight of all subjects. Create a script which will contain a vector of structures with given sample data, and then determine and print the names of subjects who are eligible. Also print the names of subjects who are not eligible, making sure to differentiate between the two. Don't assume that the length of the vector is known. Also, recall the "logical or" operator |, which you may wish to use. Name Sub ID Height Weight Fred 112 Pablo 113 Eric 114 Bob 115 Joe 111 262.0 186.3 161.9 255.4 222.5 5.3 5.6 4.4 6.7 Your output should look like this: Eligible are: Fred Pablo Eric Bob Not eligible are: oe

Explanation / Answer

Subject(1).name = Fred;
Subject(1).Sub_ID = 112;
Subject(1).Height = 5.3;
Subject(1).Weight = 262;

Subject(2).name = Pablo;
Subject(2).Sub_ID = 113;
Subject(2).Height = 6.2;
Subject(2).Weight = 186.3;

Subject(3).name = Eric;
Subject(3).Sub_ID = 114;
Subject(3).Height = 5.6;
Subject(3).Weight = 161.9;


Subject(4).name = Bob;
Subject(4).Sub_ID = 115;
Subject(4).Height = 4.4;
Subject(4).Weight = 255.4;

Subject(5).name = Joe;
Subject(5).Sub_ID = 116;
Subject(5).Height = 6.7;
Subject(5).Weight = 222.5;
totalh = 0;
totalw = 0;
for n = 1:5
totalh = totalh + Subject(n).Height;
totalw = totalw + Subject(n).Weight;
end
avgh = totalh/5;
avgw = totalw/5;
for n = 1:5
if(Subject(n).Height < avgh || Subject(n).Weight < avgw)
eleg = {eleg,n};
else
noteleg = {noteleg,n}
end
end
disp('Elegible are :');
disp(Subject(eleg).name);
disp('Not Elegible are :');
disp(Subject(noteleg).name);

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote