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

You wish to purchase carbon film resistors having a nominal value of 2.2 kohms.

ID: 3543495 • Letter: Y

Question

You wish to purchase carbon film resistors having a nominal value of 2.2 kohms. A
certain vendor sells resistors guaranteed to have values between 2.09 kohms and 2.31
kohms for $0.05 apiece and resistors guaranteed to have values between 2.178 kohms and
2.22 kohms for $0.10 apiece. You have just bought a lot of 1000 resistors selling for
$0.05 apiece. Curious about what the actual values are of the resistors you have just
purchased, you ask a college student working as a summer intern to measure them all for
you. The actual resistance values that the intern got are stored in the ASCII text file
resistors.dat that is posted with this assignment. The first column of the file contains the
resistor number, and the second column contains the resistance in ohms.
Write a MATLAB program that reads the file resistors.dat and outputs the maximum and
minimum resistance values, the number of resistors that normally would sell for $0.10
apiece, the number of resistors that normally would sell for $0.05 apiece, and the number
of resistors that would not be sold at either price to the command window with the
appropriate units. If a resistor can sell for either $0.05 or $0.10, then assume that it
normally would sell for $0.10. The resistor values in the file have units of ohms and not
kohms, so you will have to convert.


resistors.dat file here,

http://speedy.sh/6RYYn/resistors.dat

Explanation / Answer

clc

clear

a = 10^3*[2.09,2.31]; % limits for $0.05 resistors

b = 10^3*[2.178,2.22]; % limits for $0.10 resistors

file = load('resistors.dat');

n = file(:,1);

R = file(:,2);

R_min = min(R)/1000; % in Kohms

R_max = max(R)/1000; % in Kohms


n_b = length(n(find(R>=b(1) & R<=b(2)))); %number of $0.05 resistors

n_o = length(n(find(R>max([a,b]) | R<min([a,b])))); % number of resistors that can't be sold

n_a = length(n) - (n_b+n_o); %number of $0.05 resistors


x = sprintf(' maximum resistance value = %fKohms minimum resistance value = %fKohms',R_max,R_min);

disp(x)

y1 = sprintf('number of resistors that normally would sell for $0.10 apiece = %d',n_b);

disp(y1)

y2 = sprintf('number of resistors that normally would sell for $0.05 apiece = %d',n_a);

disp(y2)

y3 = sprintf('number of resistors that would not be sold at either price = %d ',n_o);

disp(y3)

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