matlab_notes-1

matlab_notes-1 - MATLAB REVIEW/TUTORIAL ME 563 C. M....

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
MATLAB REVIEW/TUTORIAL ME 563 C. M. Krousgrill School of Mechanical Engineering Table of Contents Some Matlab Basics. ................................................................................................. 1 Some Elementary Matlab Commands. ................................................................... 5 Examples of Selected Commands. .......................................................................... 10
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Matlab Notes: Some Matlab Basics 2 ME563 - cmk Some Matlab Basics The following are some basic things about Matlab that you will need to know before using the application. The list is by no means complete. You will continually learn new things every time that you use Matlab. (a) Command window The Command window is the window that first appears when you first get onto Matlab. This is the window within which you will be doing all your Matlab operations. Think of this window as being a calculator, a calculator that will allow you do perform simple arithmetic operations, scientific calculations, plotting, exporting/ importing data to/from M-files, etc. (b) Script files (M-files) If the amount of instructions given to Matlab become long and involved and will be perform repeatedly, you will find it convenient to place your instructions in a script file (known as an M-file) that can be executed as a program. • To create a new M-file , open a new file with the Notepad editor. Within the Notepad window, type your Matlab commands and the save the file. Be sure to save the file with a “.m” suffix (known as an “extension”) so that Matlab will be able to recognize it as an M-file. For example, if you want the name of your program to be main , then save the notepad file as main.m . • To modify an existing M-file , use the Notepad editor. Within the Notepad window, make the desired changes to the file. Be sure to save this file before leaving the Notepad window. • To run an existing M-file , simply type the name of the M-file (without the “.m” extension) while in the Command window. (c) Matlab variables All variables in Matlab are matrices 1 . That is, a single variable, say x, is made up of rows and columns. The symbol x(i,j) represents an element on the ith row and jth column of x. • A number, or scalar , is a matrix having only a single row and column. • A row vector is a matrix having a single row (e.g., x(1,n)). • A column vector is a matrix having a single column (e.g., x(n,1)). 1 A matrix is equivalent to an array in Fortran or C with the number of indices restricted to two.
Background image of page 2
Matlab Notes: Some Matlab Basics 3 ME563 - cmk WARNING: Actually, all variables in Matlab are also complex . Unless otherwise defined, however, the variables will contain only real parts. Within Matlab, the symbols i and j are reserved for the imaginary number -1 . That is, if you want to define a complex number x = 2 + 3i, you would simply use the command: x = 2 + 3*i; You can use the symbols i and j as name for variables other than
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 10

matlab_notes-1 - MATLAB REVIEW/TUTORIAL ME 563 C. M....

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online