90 CIRCUIT ANALYSIS TECHNIQUES

`the author of this text has developed “Electrical Machines Toolbox” for the analysis and design`

of electrical machines.

The MATLAB environment consists of a command window, a figure window, and a platform-

dependent edit window, as illustrated in Figure 2.6.2. The command window, which is the main

window, is characterized by the MATLAB command prompt>>. All commands, including

those for running user-written programs, are typed in this window at the MATLAB prompt. The

graphics window or the figure window receives the output of all graphics commands typed in the

command window. The user can create as many figure windows as the system memory would

allow. The edit window is where one writes, edits, creates, and saves one’s own programs in files

called M-files. Most programs that are written in MATLAB are saved as M-files, and all built-in

functions in MATLAB are M-files.

Let us now take an illustrative example in circuits to solve a set of simultaneous equations

with the use of MATLAB.

`0.8`

0.6

0.4

0.2

0

`0`

`Circle of radius R = 1`

`% This is the command prompt`

% Here is a simple command

`>>`

>>

`ans =`

`>> area = pix5^2 % Assign to a variable`

`area =`

`78.5398`

`4`

`2 + 2`

`-1 -0.5 0.5 1`

`-0.2`

-0.4

-0.6

-0.8

`Graphics`

window

`Command window`

`Edit window`

(with M-files)

`%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`

% This is a script file to plot a circle.

% you may specify a 'radius.'

% To execute, just type 'circle'

%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

if exist ('radius')

R = radius;

else

R = 1;

end

t=linspace(0,2*pi,100);

x=R*cos(t); y=R*sin(t);

`Figure 2.6.2Illustration of a command window, a figure window, and a platform-dependent edit window`

in the MATLAB environment.