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

On an assembly line, a machine is used to record the diameters and serial number

ID: 3800472 • Letter: O

Question

On an assembly line, a machine is used to record the diameters and serial numbers of parts (bolts) as they go by. The part serial number is recorded in a vector, Serial, and its diameter is recorded in a separate vector, Diam. Create a MATLAB function that takes (3) inputs: a scalar diameter, the desired diameter, and the tolerance for the diameter. 1. Output 1 is a 1 or a 0.1 if the serial number is within the tolerance, 0 if not 2. Output 2 should be called Location, a scalar that indicates where each part goes based on a numerical assignment of 1, 2 or 3. a. If the diameter is within the acceptable range, it should be sent to location 1 for use in the final product. b. If the part has too large of a diameter it should be sent to location 2 to be machined down in diameter. c. If the part has too small of a diameter it should be sent to location 3 to be scrapped so the material can be recycled. a Matlab Script to do the following: Enter the data presented above as appropriate vectors Run your function for each pair of serial # and diameter using a desired diameter of 100 mm, and a tolerance of plusorminus 1.5 mm. Find which serial numbers are within the tolerance & display them in a vector called Good Bolts.

Explanation / Answer

Script

serial=[2901 2903 2903 2904 2905 2906 2907 2908];
diam=[98.45 101.32 97.88 99.13 100.35 101.89 98.51 101.52];
dis_diam=100;
tol=1.5;
prompt='enter the scalar diameter';
sca_diam=input(prompt);
prompt='enter the desired diameter';
des_diam=input(prompt);
prompt='enter the tolerance';
tolerance=input(prompt);
a=compare(sca_diam,des_diam,tolerance);
disp(a);
b=1;
for i=1:8
a=compare(diam(i),dis_diam,tol);
if(a==1)
goodbolts(b)=serial(i);
b= b+1;
end
end
goodbolts

function

function [ a ] = compare( dim,ddim,tol )
lower=ddim-tol;
upper=ddim+tol;

if(lower<dim)&&(dim<upper)
a=1;
disp(a);
else
a=0;
disp(a);
end
  
if(lower<dim)&&(dim<upper)
disp('location 1');
elseif(dim>upper)
disp('location 2');
elseif(dim<lower)
disp('location 3');
end
  
end

output

>> diameter
enter the scalar diameter 100
enter the desired diameter 102
enter the tolerance 1
0

location 3
0

0

location 3
1

location 1
0

location 3
1

location 1
1

location 1
0

location 2
1

location 1
0

location 2

goodbolts =

2903 2904 2905 2907

>>