INTRODUCTION TO MATLAB (LAB SHEET 1)

Introduction to MATLAB


MATLAB (matrix laboratory) is a high-performance language for technical computing. It integrates
computation, visualization, and programming environment. It is a modern programming language
environment: it has sophisticated data structures, contains built-in editing and debugging tools, and supports object-oriented programming. These factors make MATLAB an excellent tool for teaching and research and has many advantages compared to conventional computer languages (e.g. C, Java, etc.).
The software package has been commercially available since 1984 and is now considered as a standard tool at most universities and industries worldwide. It has powerful built-in routines that enable a very wide variety of computations. It also has easy to use graphics commands that make the visualization of results immediately available. Specific applications are collected in packages referred to as toolbox. There are toolboxes for signal processing, symbolic computation, control theory, simulation, optimization, and several other fields of applied science and engineering.

Starting MATLAB


After logging into your account, you can enter MATLAB by double-clicking on the MATLAB shortcut icon (MATLAB 7.0) on your Windows desktop. Wait for the prompt (>> / EDU>) in the Command Window before typing. [Note: MATLAB 7 might give an error in Windows 7 or later versions. If so set the compatibility to Windows Vista or Windows 2000.]

Components of the MATLAB Window



  • The Command Window
  • The Command History
  • The Workspace
  • The Current Directory
  • The Help Browser
  • The Start button 



Exercises


Explore the following options in MATLAB.

  1. Set the current directory to a folder of choice.
  2. Using MATLAB as a calculator.
  3. Operator precedence.
  4. Creating MATLAB variables.
  5. Overwriting variables.
  6. Error messages and making corrections.
  7. Use of the format function.
  8. Managing the workspace.
      a. clear and clear all functions.
      b. who and whos functions.
  9. Saving the work session and workspace.
      a. diary command.
      b. MAT files.
 10. M files.
 11. Use of commas (,) or semicolons (;).
 12. Other commands in MATLAB
      a. Clear the Command Window.
      b. Abort a MATLAB computation.
      c. Continuing a line.
 13. Getting help using help, lookfor and doc commands.

Further Exercises


  1. Write a program to add 2 integers and display it in the command window.
  2. Write a program to calculate the area and the circumference of a circle, when the radius is given.
  3. Write a program to print numbers from 1 to 10.

Comments