15. Amachine cuts N pieces of a pipe. After each cut, each of pipe is weighed pi
ID: 3935920 • Letter: 1
Question
15. Amachine cuts N pieces of a pipe. After each cut, each of pipe is weighed piece and its length is measured; these two values are then stored in a file called pipedat (first the weight and then the length on each line of the file). Ignoring units, the weight is supposed to be between 2.1 and 2.3, inclusive, and the length is supposed to be between 103 and 104, inclusive. The following is just the begin ning of what will be a long script to work with these data. For now, the script will just count how many rejects there are A reject is any piece of pipe that has an
Explanation / Answer
fid = fopen('pipe.dat');
r = 0;
while ~feof(fid)
t1 = fgets(fid);
c = textscan(t1,'%f %f');
w = c{1};
l = c{2};
%disp(w);
%disp(l);
if (w < 2.1 || w > 2.3)
r = r + 1;
end
if (l < 10.3 || l > 10.4)
r = r + 1;
end
end
fprintf(' There were %d rejects. ', r);
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.