CU Mechanical Engineering

course specific Matlab tutorials



The Matlab Workspace

Matlab, short for 'Matrix Laboratory,' is among the most powerful mathematics programs available for commercial use, particularly for numerical work. Matlab come equipped with a sustantial library for doing most operations you could ever think of and the ability to create your own functions and programs to provide and infintely customizeable mathematics interface. In order to begin using Matlab, we will start with the basics and gradually introduce more complicated topics.

Accessing Help

Perhaps the best place to start is by introducing that infinte source of knowledge, the matlab help library. This can be accessed by pressing the button with a quesion mark at the top of the screen or simply typing 'help' at the command prompt.

>> help
[a long list of help topics follows]

To get more help on a specific topic or function, type 'help' followed by the command.

>> help fft
[a help message on the fft function follows].

The Matlab Environment

The Matlab environment is very similar to a Unix shell if you are familiar with that (and if you are, don't fear) and some commands are the same. It is slightly different than the graphical interface you might be used to, but it can do pretty much anything you might need.

Basic operations such as addition, multiplication are very intuitive and just as you would expect:

>> 4+5

ans = 

     9

>> 3^3

ans = 

     27
	 
>> 2*(2+1)^2

ans = 

     18

>> ans

ans = 

     18

Matlab conveniently stores the answer to the last operation as the variable 'ans' which can be used by like any other variable. If you would ever like to suppress the output of an operation, simply follow the statement with a semicolon. The answer is still stored but the output will not be displayed on the screen.

>> 4+5;
>> ans

ans = 

     9
	 
>> ans+5

ans = 

     14

Now that you know the basics of how matlab works, we can now introduce the next building blocks, vectors!


Click here to go back to the tutorials home page.