24-11-2012, 06:34 PM
PROGRAMMING MAT LAB
02 Matlab Tutorial.pdf (Size: 441.38 KB / Downloads: 38)
INTRODUCTION
Files that contain a computer code are called the m-files. There are two kinds of m-files: the script
files and the function files. Script files do not take the input arguments or return the output
arguments. The function files may take input arguments or return output arguments.
To make the m-file click on File next select New and click on M-File from the pull-down menu.
You will be presented with the MATLAB Editor/Debugger screen. Here you will type your
code, can make changes, etc. Once you are done with typing, click on File, in the MATLAB
Editor/Debugger screen and select Save As… . Chose a name for your file, e.g., firstgraph.m
and click on Save. Make sure that your file is saved in the directory that is in MATLAB's search
path.
Two data types the cell arrays and structures make MATLAB a powerful tool for applications.
They hold other MATLAB arrays. In this section we discuss the cell arrays only. To learn about
structures the interested reader is referred to [4], Chapter 13 and [1], Chapter 12.
To create the cell array one can use one of the two techniques called the cell indexing and the
content indexing. The following example reveals differences between these two techniques.
Suppose one want to save the string 'John Brown' and his SSN 123-45-6789 (without dashes) in
the cell array.