MATLAB programming - Script Files -
this example, we are going to program the plotting of two concentric
circles and mark the center point with a black square. We use polar
coordinates in this case (for a variation).
We can open a new edit
window and type the following program (script). As already
mentioned, lines starting with a '%'
sign are comments,
and are ignored by MATLAB but are very useful to the viewer.
% The initial
instructions clear the screen, all
% of the
variables, and close any figure
% CIRCLE - A
script file to draw a pretty circle
% We first
generate a 90-element vector to be used as an angle
angle = linspace(0,
% Then, we
create another 90-element vector containing only value 2
r2 = linspace(2,
% Next, we
plot a red circle using the 'polar' function
% We avoid
deletion of the figure
% Now, we
create another 90-element vector for radius 1
r1 = linspace(1,
% Finaly, we
mark the center with a black square
We save the script and run it with the 'run' icon (within
Or we can run it from the Command
Window by typing the name of the script.
We now get the concentric circles:
Programming' to 'Matlab Examples'