© Dr. James S. Kang, Professor, ECE Department, Cal Poly Pomona
Opening MATLAB
Start → Programs → MATLAB → R2010a → MATLAB R2010a
or double click on icon (
). Slightly different for different versions and operating systems. The MATLAB window opens up as shown below. Depending on Desktop options, the window looks different. Set the Current Folder on top of the screen.
Working on Command Window
We are demonstrating the use of Command Window by solving HW Problem 1.9
1.9 The diameter of a 26 AWG copper (conductivity = σ = 5.69 × 107 S/m) wire is 0.405mm.
Find the resistance of the copper wire when the length of the wire is
1
(a) = 20m
(b) = 200m (c) = 2km
(d) = 20km
Enter clear all; after >> as shown below.
>> clear all;
Clear all clears previously defined variables and start new. Then, type format compact;
>> format compact;
Format compact suppress extra blank line in the answers. If you want to restore extra blank line, type in format loose. Semicolon indicates the end of an instruction. If you want to see the answer, do not enter semicolon. Enter diameter, σ, length as follows:
>> d=0.405e-3;sigma=5.69e7;l=20;
The radius r is found by dividing the diameter by 2:
>> r=d/2 r =
2.0250e-004
The cross sectional area of the conductor is given by
>> A=pi*r^2
A =
1.2882e-007
The resistance is given by
>> R=l/(sigma*A)
R =
2.7285
To change the length to 200m, press up arrow (↑) several times to get to the line
>> d=0.405e-3;sigma=5.69e7;l=20;
Change 20 to 200 and press Enter:
>> d=0.405e-3;sigma=5.69e7;l=200;
Press arrow (↑) several times to get to the line
>> r=d/2
and press Enter. Repeat this procedure for A and R to get r =
2.0250e-004
2
>> A=pi*r^2
A =
1.2882e-007
>> R=l/(sigma*A)
R =
27.2846
Repeating the above procedure, calculate resistance values for = 2km and = 20km. Rather than using arrows (↑, ↓), it is easier to modify the code by creating MATLAB script.
Creating MATLAB Script
Click File → New →Script.