Question: please write in matlab! A machine is designed to cut feeding materials into small parts. After each cut, the width and length of the part

please write in matlab!
A machine is designed to cut feeding materials into small parts. After each
cut, the width and length of the part are measured. These 2 values are then stored in a data
file.
The enclosed parts1.dat and parts2.dat are two examples of such recorded files. Each row
in the data file stores the two measurements for each part: the width, followed with the
length.
Write a function to read in such a data file and count total number of parts stored in the
file and the number of rejected parts. A part is rejected if its area (Area = Width \times Length)
is greater than 21.5.
The function shall have one input argument, which is the file path of the data file. The
function shall have two output arguments: number of rejects and total number of parts in
the file.
Requirement:
Please implement this function using for-loop;
Read in data using importdata() function.
Your function should produce the same outputs as below (the exact values may vary due to
data change, but the format must be the same). Please note if the parts1.dat and parts2.dat
are in the current folder with your function, we only need to use the file name instead of
the full file path.
>>[A,B]= CountRejects('parts1.dat')
A =
4
B =
50
>>[R,N]= CountRejects('parts2.dat')
R =
4
N =
100

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!