PRACTICAL MATLAB® FOR ENGINEERS PRACTICAL MATLAB

(sharon) #1

14 2 Practical MATLAB® Applications for Engineers


ANALYTICAL Solution
From Table 2.2, the nominal value of R is given by

R = (^10) 103  = 10 k 
and the range of the resistor R (tolerance) is given by
(10
103 ) − (10 (^103) 0.1) ≤ R ≤ (10 103 ) + (10 (^103) 0.1)
then
9,000  ≤ R ≤ 11,000 
The fi fth color band indicates the reliability of R, that is, 0.01. In the present case, it indi-
cates that one in every 100 resistors would fail during the fi rst 1000 hours of usage.
Having defi ned the color code of resistors, we next proceed to write the MATLAB
script fi le colorcode, which returns the nominal value of a given resistor R, its tolerance
and reliability factor, given its color-coded specs. The program is then tested for the
resistor with the following color specs: brown, green, orange, silver, and red.
MATLAB Solution
% Script file: color
code
% Color Code Program
Color1 = char(‘Brown=1’, ‘Red=2’, ‘Orange=3’, ‘Yellow=4’, ‘Green=5’,’Blue=6’,
‘Violet=7’, ‘Gray=8’,’White=9’);
disp (‘The first color band, with its numerical values are given below:’);
disp (Color1)
A=input(‘Enter the numerical value of the first band, A=’);
disp(‘ ’)
Color2=char(‘Black=0’, Color1);
disp(‘The second color band, with its numerical values are given below:’);
disp(Color2)
B=input(‘Enter the numerical value of the second ban, B=’);
disp(‘ ’)
C o l o r 3 = c h a r(‘S i lv e r= -2’, ‘G o l d = -1’, C o l o r 2);
disp(‘The third color band, with its numerical values are given below:’);
disp(Color3)
C=input(‘Enter the numerical value of the third band, C=’);
disp(‘ ’)
Color4=char(‘Gold=0.05’, ‘Silver=0.1’,’Noband=0.2’);
disp(‘The forth color band, with its numerical values are given below:’);
disp(Color4)
D=input(‘Enter the numerical value of the fourth band, D=’);
disp(‘ ’)
Color5=char(‘Brown=0.01’, ‘Red=0.001’,’Orange=0.0001’,’Yellow=0.00001’);
disp(‘The fifth color band, with its numerical values are given below: ‘);
disp(Color5)
E=input(‘Enter the numerical value of the fifth band, E=’);
disp(‘ ’)
R=(A
10+B)10^C;
Rmin=R-R
D;Rmax=R+R*D;

Free download pdf