INTRODUCTION TO MATLAB
© Dr. James S. Kang, Professor, ECE Department, Cal Poly Pomona
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
(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:
The radius r is found by dividing the diameter by 2:
>> r=d/2 r =
The cross sectional area of the conductor is given by
The resistance is given by
To change the length to 200m, press up arrow (↑) several times to get to the line
Change 20 to 200 and press Enter:
Press arrow (↑) several times to get to the line
and press Enter. Repeat this procedure for A and R to get r =
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.