An icon link for MATLAB should be available on the Desktop of each computer in a CNC lab. Across campus, you may have to page throught the START menu and into PROGRAMS before you find a link to the executable.


Either way, once you launch the package something close to the following should appear:


Note the command line prompt “>>”

It is from this command line you will issue all MATLAB commands. MATLAB is a command interpreter NOT a high level programming language. However, you can write “programs” that are more correctly called “scripts” or “.m” files because a file with a “.m” extension will often be recognized as a MATLAB script. These scripts are in many ways like macros you may have composed using Excel or a similar spreadsheet program.

To get started, type each commands one at a time from the command window: helpwin, helpdesk and demo. After entering each command, spend some time reading JUST the INTRODUCTORY materials

Here, we are going to get you started by looking at the demo option:

>> demo

As you proceed with your reading you will see there are actually many different demos, all accessible from a demo window that is popped up when you type "demo" at the command prompt. You are not really expected to learn the details of using MATLAB through these demos, but rather just to get a good feel for all the kinds of things you can use MATLAB for. There are even some games you can play in these demos, and most of the demos have quite visually appealing graphics, so you should enjoy going through these demos. Again, don't stress out about trying to understand details, but just try to get an overall feel for what kind of a tool MATLAB is, what kinds of problems you can use it for, and generally how you use it. MATLAB is a very practical and powerful tool for solving many different types of problems, and you should appreciate this more after going through some of the demos.

So, to start the MATLAB demos type "demo" at the command prompt and then hit the enter key. The MATLAB demo window should then pop up and wait for you to choose and run the various demos; the MATLAB demo window looks like this:

We won't go through all the demos here in this tutorial, but rather get you going by showing you how to start one of them. You can then work through some of the others similarly at your own pace.

Anyway, the text box at the left (i.e., the one labeled “Help Navigator” contains the demo categories. Within each of these categories are several individual demos. Go ahead and select "Gallery" within your own open MATLAB demo window. Then, select "Spherical Surface Harmonic" from the list of possible images links. Here the image looks something like this:

But you also see a lot of commands that look like this:

% Define constants.

degree = 6;

order = 1;


% Create the grid

delta = pi/40;

theta = 0 : delta : pi; % altitude

phi = 0 : 2*delta : 2*pi; % azimuth

[phi,theta] = meshgrid(phi,theta);


% Calculate the harmonic

Ymn = legendre(degree,cos(theta(:,1)));

Ymn = Ymn(order+1,:)';

yy = Ymn;

for kk = 2: size(theta,1)

    yy = [yy Ymn];


yy = yy.*cos(order*phi);


order = max(max(abs(yy)));

rho = 5 + 2*yy/order;


% Apply spherical coordinate equations

r = rho.*sin(theta);

x = r.*cos(phi);    % spherical coordinate equations

y = r.*sin(phi);

z = rho.*cos(theta);


% Plot the surface




lighting phong


axis([-5 5 -5 5 -5 5])



These are the individual “commands” that will create this image. In fact, if you copy and paste ALL of these commands into the command window and release them at the command prompt “>>” you will generate a graph very much like you see above. This is a GREAT way to learn how many commonly used MATLAB command work and what options you have for using them.

To continue on to the next lesson, click here.