Basic MATLAB Programming Course

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 155

Basic MATLAB

Programming Course
What we will learn in this session

 The basic MATLAB interface.


 Basic commands.
 Declaring & manipulating variables.
 Plotting graphs.
 Conditional Operators.
 Functions.
Basic MATLAB
Interface
Command window: Type your
instructions here and press
ENTER to execute them.
Example: Declare a column matrix with
values 1,2 and 3.
Command history: a list of instructions
executed by MATLAB is shown here.
Workspace: shows a list of
variables created by MATLAB.
As you can see, the value of ‘aaa’
is shown.
Another way to create a variable
Is to press this button.
MATLAB will prompt you to enter
the variable name.
As you can see, the variable
name has been changed to bbb.
2) Or by double clicking
on bbb.

To assign a value to bbb, you can do it in


two ways: 1) Using the command window.
When you click on bbb, the variable
editor window appears. You can type
in new values into bbb by filling in the
cells.
An example is shown here.
Try and do it yourself.
To display variables at the console,
you can type the variable name,
or you can type disp(variable_name).
To clear all variables from
memory and close all
figures, use the
clear, close all command.
As you can see, all workspace
variables are deleted when
you execute this command.
To clear the command window,
use the clc (clear console) command.
As you can see, all console
entries are deleted when
you execute this command.
If you want to see help,
you can type help at the
command window.
Or you can press F1
to display the help
window. Click on
Open Help Browser
to search for a
specific function.
Example: search for
function mean
To create an m-file, 1) type edit at
the command window, or
2) Press this button.
The previous command will
display the editor window.
The editor creates an m-file
that can be used to write
your MATLAB programs.
To execute a program, press
the RUN button.
This window will appear. Press the
Change Directory button.
You can see that the program has
created two new variables in the
Workspace.
MATLAB BASICS

Summary
• help command  Online help
• lookfor keyword  Lists related commands
• which  Version and location info
• clear  Clears the workspace
• clc  Clears the command window
• diary filename  Sends output to file
• diary on/off  Turns diary on/off
• who, whos  Lists content of the workspace
• more on/off  Enables/disables paged output
• Ctrl+c  Aborts operation
• …  Continuation
• %  Comments
Basic Commands
MATLAB BASICS
Variables and Arrays
 Array: A collection of data values organized into
rows and columns, and known by a single name.

Row 1

Row 2

Row 3
arr(3,2)
Row 4

Col 1 Col 2 Col 3 Col 4 Col 5


MATLAB BASICS
Arrays
 The fundamental unit of data in MATLAB
 Scalars are also treated as arrays by MATLAB
(1 row and 1 column).
 Row and column indices of an array start from 1.
 Arrays can be classified as vectors and
matrices.
MATLAB BASICS
 Vector: Array with one dimension
 Matrix: Array with more than one dimension
 Size of an array is specified by the number of rows
and the number of columns, with the number of
rows mentioned first (For example: n x m array).
Total number of elements in an array is the
product of the number of rows and the number of
columns.
MATLAB BASICS
1 2
a= 3 4 3x2 matrix  6 elements
5 6

b=[1 2 3 4] 1x4 array  4 elements, row vector

1
c= 3 3x1 array  3 elements, column vector
5

a(2,1)=3 b(3)=3 c(2)=3

Row # Column #
Declaring Single Variables
 To declare single variables, type in a
variable name and type in its value.
 MATLAB will decide on the data type
automatically, so you don’t have to declare
its data type.
 Example:
 var1 = 3;
 thisIsAVariable = 56;
Declaring Single Variables
 Variables cannot have numbers or
symbols in front of them.
 Example of illegal variable names:
 1var
 #aaa
Special Values/Variables
• pi:  value up to 15 significant digits
• i, j: sqrt(-1)
• Inf: infinity (such as division by 0)
• NaN: Not-a-Number (division of zero by zero)
• clock: current date and time in the form of a 6-element
row vector containing the year, month, day, hour,
minute, and second
• date: current date as a string such as 16-Feb-2004
• eps: epsilon is the smallest difference between two
numbers
• ans: stores the result of an expression
Vectors
Some useful commands:

x = start:end create row vector x starting with start, counting by


one, ending at end

x = start:increment:end create row vector x starting with start, counting by


increment, ending at or before end
linspace(start,end,number) create row vector x starting with start, ending at
end, having number elements
length(x) returns the length of vector x

y = x’ transpose of vector x

dot (x, y) returns the scalar dot product of the vector x and y.
Examples-Vectors
Real Scalars
>> x = 5
x=5
Row Vector (1 x 3)
>> x = [ 1 2 3 ]
x=
1 2 3
Column Vector ( 3 x 1)
>> x = [ 1 ; 2 ; 3 ]; %”;” suppresses output
>> x
x=
1
2
3
Note: Variable Names are case sensitive
Matrix Variables
 Matrix variables are initialized similar to
single variables.
 The values in a matrix variable is defined
in square brackets.
 Example:
 aaa = [1,2,3,4];
 bbb = [1;2;3;4];
Row Matrix
 To create a row matrix, use the comma to
separate the values.
 Example:
 rowMatrix = [1,2,3,4,5];
Example
•Rows and columns are always numbered starting at 1

•Matlab matrices are of various types to hold different


kinds of data (usually floats or integers)

• A single number is really a 1 x 1 matrix in Matlab!

• Matlab variables are not given a type, and do not need


to be declared

• Any matrix can be assigned to any variable


Try It Yourself
 Create a row matrix named var1 with the
values of 1, 3, 5 in it.
 Create a row matrix named mat1 with the
values of 10, 20, 30, 40, 50, 60 in it.
 Create a row matrix named var2 with the
values of 1, 3, 5, 6, 8, 10, 11 in it.
Column Matrix
 To create a column matrix, use the
semicolon to separate the values.
 Example:
 colMatrix = [1;2;3;4;5];
Example
Try It Yourself
 Clear and close all variables, and clear console.
 Create a column matrix named col1 with the
values of 2, 6, 9 in it.
 Create a column matrix named mat3 with the
values of 15, 23, 37, 48, 59, 61 in it.
 Create a column matrix named colMatrix with
the values of 1, 3, 5, 6, 8, 10, 11 in it.
Regular Matrix
 To create a regular matrix, use the comma
to separate each value in a row, and a
semicolon to enter the value for a new
row.
 Example:
 mat1 = [1,2,3;4,5,6;7,8,9];
Example
Building matrices with [ ]:

A = [2 7 4] 2 7 4

A = [2; 7; 4] 7

2 7 4

A = [2 7 4; 3 8 9] 3 8 9

2 7 4 2 7 4
B=[AA] ? 3 8 9 3 8 9
Try It Yourself
 Create this matrix:

1 2
A 
3 4 
Try It Yourself
 Create this matrix:

 2 4 5

matrixB  2 4 5 
5 3 5
Accessing Matrix Values
 To access a specific value inside a matrix,
use this command:
 matrixName(rowNumber, colNumber)
 Example: to access a value inside row 3
and column 2.
 matrixName(3,2)
Try It Yourself
 Create this matrix:

3 4 5 

matrixB  8 9 10 
6 7 1 

 Try to get values 9, 3 and 1 from the matrix


and save it into three variables.
Accessing Whole Columns and
Rows
 To get a whole column, use this
command:
 varA = matName(:,colNumber);
 To get a whole row, use this command:
 varA = matName(rowNumber,:);
Accessing Matrix Elements
>> A= [ 1 2 3 ; 4 5 6 ; 7 8 9];

>> x = A ( 1, 3 ) %A(<row>,<column>)
x=
3

>> y = A ( 2 , : ) % selects the 2nd row


y=
4 5 6

>> z = A ( 1:2 , 1:3 ) % selects sub-matrix


z=
1 2 3
4 5 6
Example
Try it Yourself
 Create this matrix:

3 4 5 
matrixB  8 9 10
6 7 1 
 Get all the values from row 3 and save it into a new
variable.
 Get all the values from column 1 and save it into a new
variable.
Creating a Matrix of Zeros
 To create a matrix of zeros, use the zeros
command.
 Example: create a 6 X 5 matrix of zeros.
 zeros(6,5)
Example
Creating a Matrix of Ones
 To create a matrix of ones, use the ones
command.
 Example: create a 5 X 3 matrix of ones.
 ones(5,3)
Example
Creating a Matrix of Random
Numbers
 To create a matrix of random numbers,
use the rand command.
 Example: create a 4 X 4 matrix of random
numbers.
 rand(4,4)
Example
>> B = [ 1 2 ; 8 9 ]
ans =
1 2
8 9

>> ones(2,2) % generates an all ones 2 x 2 matrix


ans =
1 1
1 1

>> zeros(2,3) % generates an all zero 2 x 3 matrix


ans =
0 0 0
0 0 0

>> rand(3,3) % generates a random 3 x 3 matrix


ans =
0.4447 0.9218 0.4057
0.6154 0.7382 0.9355
0.7919 0.1763 0.9169

>> eye(2) % generates the 2 x 2 identity matrix


ans =
1 0
0 1
Getting the Size of the Matrix
 To get the size of the matrix, use the size
command.
 Example: to get the size of matrix aaa.
 [numRow, numCol] = size(aaa);
Example
Concatenating, Appending, …
>> R = [ 1 2 3 ] ;
>> S = [ 10 20 30 ] ;
>> T = [ R S ]
T=
1 2 3 10 20 30
>> Q = [ R ; S ]
Q=
1 2 3
10 20 30
>> Q ( 3, 3 ) = 100
Q=
1 2 3
10 20 30
0 0 100
Some Useful Functions
Some useful math functions:
sin(x), cos(x), tan(x), atan(x), exp(x), log(x), log10(x), sqrt(x)

>> t = [ 0 : 0.01 : 10 ];
>> x = sin ( 2 * pi * t );

Some useful matrix and vector functions:


>> size (A)
ans =
3 3
>> length ( t )
ans =
1001
Finding the Maximum Value
 To find the maximum value for a matrix,
use the max function.
 Example: find the maximum value in
matrix aaa.
 maxVal = max(aaa);
Example

Max finds the


maximum value
in each column

When it is run again


on the result, it
returns the single-largest
value in the matrix.
Finding the Minimum Value
 To find the minimum value for a matrix,
use the min function.
 Example: find the minimum value in matrix
aaa.
 minVal = min(aaa);
Example

Min finds the


minimum value
in each column

When it is run again


on the result, it
returns the minimum
value in the matrix.
More Operators and Functions
For vectors, SUM(X) is the sum of the elements of X. For matrices, SUM(X) is a row
vector with the sum over each column.

>> sum ( A )
ans =
12 15 18

>> sum ( ans ) % equivalent to sum(sum(A))


ans =
45

>> A’ % equivalent to transpose(A)


ans =
1 4 7
2 5 8
3 6 9

>> diag(A)
ans =
1
5
9
At a glance……..
• Initializing with Built-in Functions

• zeros(n), >> a = zeros(2);


• zeros(n,m) >> b = zeros(2, 3);
• zeros(size(arr)) >> c = [1, 2; 3, 4];
• ones(n) >> d = zeros(size(c));
• ones(n,m)
• ones(size(arr))
• eye(n)
• eye(n,m)
• length(arr)
• size(arr)
• magic(m)
• pascal(m)
Some Built-in functions
 mean(A):mean value of a vector
 max(A), min (A): maximum and minimum.
 sum(A): summation.
 sort(A): sorted vector
 median(A): median value
 std(A): standard deviation.
 det(A) : determinant of a square matrix
 dot(a,b): dot product of two vectors
 Cross(a,b): cross product of two vectors
 Inv(A): Inverse of a matrix A
Matrices
more commands
Transpose B = A’
Identity Matrix eye(n)  returns an n x n identity matrix
eye(m,n)  returns an m x n matrix with ones on the main
diagonal and zeros elsewhere.
Addition and subtraction C=A+B
C=A–B
Scalar Multiplication B = A, where  is a scalar.
Matrix Multiplication C = A*B
Matrix Inverse B = inv(A), A must be a square matrix in this case.
rank (A)  returns the rank of the matrix A.
Matrix Powers B = A.^2  squares each element in the matrix
C = A * A  computes A*A, and A must be a square matrix.
Determinant det (A), and A must be a square matrix.
A, B, C are matrices, and m, n,  are scalars.
Adding Matrices
 To add matrices, use the + operator.
 Example: add matrices A and B.
A + B.
 Make sure that the matrices are the same
size.
Example
Subtracting Matrices
 To subtract matrices, use the - operator.
 Example: subtract matrix B from A.
A - B.
 Make sure that the matrices are the same
size.
Example
Multiplying Matrices
 To multiply matrices, use the .* operator.
 Example: multiply matrices A and B.
A .* B.
 Make sure that the matrices are the same
size.
Example
Dividing Matrices
 To divide matrices, use the ./ operator.
 Example: divide matrices A with B.
A ./ B.
 Make sure that the matrices are the same
size.
Example
Operators (relational, logical)
 == Equal to
 ~= Not equal to
 < Strictly smaller
 > Strictly greater
 <= Smaller than or equal to
 >= Greater than equal to
 & And operator
 | Or operator
Logical Indexing
>> r = results(:,1)
>>ind=r>0.2
>>r(ind)

89
Sorting Matrices
 To sort a matrix, use the sort command.
 Example: sort matrix A in ascending order.
B = sort(A,’ascend/descend’)
 Default is ascending mode.
Example: Sorting a Row Matrix
Example: Sorting a Column Matrix
Example: Sorting a Regular Matrix
Example: Sorting a Row Matrix in
Descend Mode
Flipping a Matrix
 A matrix can be flipped using the flipud or
fliplr commands.
 Command flipud flips the matrix in
UP/DOWN direction.
 Command fliplr flips the matrix in
LEFT/RIGHT direction.
Example: flipud
Example: fliplr
Term by Term vs Matrix Operations
>> B = [ 1 2 ; 3 4 ] ;
B=
1 2
3 4

>> C = B * B % or equivalent B^2


C=
7 10
15 22

>> D = B .* B % or B.^2 The Dot denotes term by term operations


D=
1 4
9 16
Operators (Element by Element)

.* element-by-element multiplication
./ element-by-element division
.^ element-by-element power
Initializing with Keyboard Input

• The input function displays a prompt string in the


Command Window and then waits for the user to
respond.

my_val = input( ‘Enter an input value: ’ );

in1 = input( ‘Enter data: ’ );

in2 = input( ‘Enter data: ’ ,`s`);


Strings
 MATLAB also can accept and manipulate
string variables.
 A string is defined by enclosing it in single
quotes.
 Example: aString = ‘Hello World!’
Example: Initializing a String
Converting a String to Lowercase

 To convert a string to lowercase, use the


lower command.
 Example: change string in matrix A to
lowercase:
B = lower(A)
Example: Change String to
Lowercase
Converting a String to Uppercase

 To convert a string to uppercase, use the


upper command.
 Example: change string in matrix A to
uppercase:
B = upper(A)
Example: Change String to
Uppercase
Concatenate Strings
 Concatenating string means merging two
or more strings together.
 To concatenate strings, use the strcat
command.
 Example: to concatenate str1 and str2:
 newStr = strcat(str1,str2)
Example: Concatenate String
Replace String
 To replace part of the string with a new
value, use the strrep command.
 Example: replace the word ‘lama’ with the
word ‘baru’ in the string str1.
 strrep(str1,’lama’,’baru’)
Example: Replace String
The num2str() and int2str() functions
>> d = [ num2str(16) '-Feb-' num2str(2004) ];
>> disp(d)
16-Feb-2004
>> x = 23.11;
>> disp( [ 'answer = ' num2str(x) ] )
answer = 23.11
>> disp( [ 'answer = ' int2str(x) ] )
answer = 23
MATLAB BASICS
The fprintf( format, data ) function
– %d integer
– %f floating point format
– %e exponential format
– %g either floating point or exponential
format, whichever is shorter
– \n new line character
– \t tab character
MATLAB BASICS
>> fprintf( 'Result is %d', 3 )
Result is 3
>> fprintf( 'Area of a circle with radius %d is %f', 3, pi*3^2 )
Area of a circle with radius 3 is 28.274334
>> x = 5;
>> fprintf( 'x = %3d', x )
x= 5
>> x = pi;
>> fprintf( 'x = %0.2f', x )
x = 3.14
>> fprintf( 'x = %6.2f', x )
x = 3.14
>> fprintf( 'x = %d\ny = %d\n', 3, 13 )
x=3
y = 13
MATLAB BASICS

Data files
• save filename var1 var2 …
>> save myfile.mat x y 
binary
>> save myfile.dat x –ascii  ascii
• load filename
>> load myfile.mat  binary
>> load myfile.dat –ascii  ascii
Loading & saving Excel files
% Create an Excel file named myExample.xlsx.

values = {1, 2, 3 ; 4, 5, 'x' ; 7, 8, 9};


headers = {'First','Second','Third'};
xlswrite('myExample.xlsx',[headers; values]);

% Read numeric data from the first worksheet

filename = 'myExample.xlsx';
A = xlsread(filename)
Built-in MATLAB Functions
• result = function_name( input );
– abs, sign
– log, log10, log2
– Exp
– sqrt, std
– sin, cos, tan
– asin, acos, atan
– max, min
– mean, median, mode
– round, floor, ceil, fix
– mod, rem
• help elfun  help for elementary math functions
 Passing a vector to a function like sum, mean, std
will calculate the property within the vector
>> sum([1,2,3,4,5])
= 15

>> mean([1,2,3,4,5])
=3
Cell
C = cell(2,2); % create a 2 by 2 cell

C{1,1} = rand(3);% put a 3x3 random matrix in the 1st box


C{1,2} = char('john','raj');% put a string array in the 2nd box
C{2,1} = 3;% put a number in the 3rd box
C{2,2} = cell(3,3);% put a 3x3 cell in the 4th box
 Meshgrid
[X,Y] = meshgrid(1:3,10:14)

X=

1 2 3
1 2 3
1 2 3
1 2 3
1 2 3
Some important built-in functions

meshgrid -

[X,Y] = meshgrid(1:3,10:14)

X= Y=

1 2 3 10 10 10
1 2 3
11 11 11
1 2 3
12 12 12
1 2 3
1 2 3 13 13 13
14 14 14
Repmat -Repeat copies of array

A = diag([100 200 300])


B = repmat(A,2)

A= B=

100 0 0 100 0 0 100 0 0


0 200 0 0 200 0 0 200 0
0 0 300 0 0 300 0 0 300
100 0 0 100 0 0
0 200 0 0 200 0
0 0 300 0 0 300
Conditional
Operators
If…else Operator
 The if…else operator tests a condition.
 If the condition is true, then execute the if
block.
 If the condition is false, execute the else
block.
If…else Operator
if (condition)
% if block
else
% else block
end

% conditions that can be tested


% == : is equal to
% ~= : is not equal to
% > : larger than
% >= : larger than or equal
% <= : less than or equal
% < : less than
Example
clear, close all
clc

aaa = rand(1,100);
bbb = 1:1:100

color = 1;

if (color == 1)
% if block
figure, plot(bbb,aaa,':r');
else
% else block
figure, plot(bbb,aaa,'b');
end
Example
clear, close all
clc

x = 3;

if (x > 5)
disp('The number is more than 5.')
elseif (x == 5)
disp('The number is equal to 5.')
else
disp('The number is less than 5.')
end
For loop
 Used to repeat a set of statements
multiple times.
 The for loop format is:
 for(startingvalue:increment:endingvalue)
For Loop

clear, close all


clc

% i is the value of the counter


for i = initial_value:increment:ending_value

% statements in this block will be executed


until i
% reaches the ending_value

end
Example: Display value inside for
loop
clear, close all
clc

for i = 1:1:15
st1 = strcat('The value of i inside the
loop is: ',int2str(i));
disp(st1)
end
Example: Display “Hello World” 10
Times
st1 = 'Hello World!';

for i = 1:1:10
disp(st1)
end
Example: Check Value Inside
Matrix
clear, close all
clc

matA = [1.4,4.2,6.7,7.0; 5.5,6.7,8.9,3.0; 0.6,6.12,5.44,8.94]


[row,col] = size(matA)

for i = 1:1:row
for j = 1:1:col

currNo = matA(i,j);
st1 = strcat('The value being tested is: ', num2str(currNo),'.');
disp(st1)

if (currNo > 3)
disp('The current value is larger than 3.')
else
disp('The current value is less or equal than 3.')
end

end
end
While loop
 Used to repeat a set of statements while
the tested condition is true.
 The while loop format is:
 while(condition)
 The tested condition is the same as if…
else
Conditions that can be tested
% conditions that can be tested
% == : is equal to
% ~= : is not equal to
% > : larger than
% >= : larger than or equal
% <= : less than or equal
% < : less than
Example: Display value inside for
loop
clear, close all
clc

counter = 1;

while(counter <= 15)


st1 = strcat('The value of i inside the loop is:
',int2str(counter));
disp(st1)
counter = counter + 1;
end
Example: Display “Hello World” 10
Times
clear, close all
clc

st1 = 'Hello World!';


counter = 1;

while(counter <= 10)


disp(st1)
counter = counter + 1;
end
Functions
Functions
 A complex program may be divided into
several functions.
 These functions can improve readability of
the code, as well as promote re-usability of
the code.
 Each function must be saved into a
different file, with the filename similar to
the function.
Function
 The format of a function is:
 function returnValue = fcnName(inputValue)
Example
function hasil = addFcn(number1, number2)

hasil = number1 + number2;

% to call this function, call the fcn name


% using your own parameters.
% e.g. c = addFcn(3,4)
% e.g. c = addFcn(a,b)
Example: Using Functions
clear, close all
clc

number1 = 4;
number2 = 5;
selection = 1;

if selection == 1
hasil = addFcn(number1,number2);
elseif selection == 2
hasil = subFcn(number1,number2);
elseif selection == 3
hasil = mulFcn(number1,number2);
elseif selection == 4
hasil = divFcn(number1,number2);
else
disp('The selection is invalid.')
end

disp(strcat('The result is:', num2str(hasil)));


addFcn
function hasil = addFcn(number1, number2)

hasil = number1 + number2;


subFcn
function hasil = subFcn(number1, number2)

hasil = number1 - number2;


mulFcn
function hasil = mulFcn(number1, number2)

hasil = number1 * number2;


divFcn
function hasil = divFcn(number1, number2)

hasil = number1 / number2;


Sample Problems
Initializing Variables in Assignment Statements
An assignment statement has the general form
var = expression
Examples:
>> var = 40 * i; >> a2 = [0 1+8];
>> var2 = var / 5; >> b2 = [a2(2) 7 a];
>> array = [1 2 3 4]; >> c2(2,3) = 5;
>> x = 1; y = 2; >> d2 = [1 2];
>> a = [3.4]; >> d2(4) = 4;
>> b = [1.0 2.0 3.0 4.0];
>> c = [1.0; 2.0; 3.0];
>> d = [1, 2, 3; 4, 5, 6]; ‘;’ semicolon suppresses the
>> e = [1, 2, 3 automatic echoing of values but
4, 5, 6]; it slows down the execution.
Problem 1
 Write a program that
calculates and displays
the volume of a sphere
4 3
V  j
when given the radius.
The volume calculation
must be performed in a


function called
calcSphereVolume.
The formula for volume
3
is:
Problem 2
 Write a program that plots the function:

y  x  x  3x  6
3 2

 for values of x = -50 to 50


Problem 3
 Generate a 100x50 matrix of random
numbers called A.
 For each value inside the matrix, if the
value is above 0.5, change its value to 1.
If it is below 0.5, change its value to zero.
 Then, count and display how many ones
inside the matrix.
Plot the function e-x/3sin(x) between
0≤x≤4π
 Create an x-array of 100 samples between 0 and
4π.

 Calculate sin(.) of the x-array

 Calculate e-x/3 of the x-array

 Multiply these two arrays


Basic Task: Plot the function sin(x)
between 0≤x≤4π
 Create an x-array of 100 samples between 0 an
4π.

>>x=linspace(0,4*pi,100);

 Calculate sin(.) of the x-array


1

0.8

0.6

>>y=sin(x); 0.4

0.2

 Plot the y-array -0.2

-0.4

-0.6

>>plot(y) -0.8

-1
0 10 20 30 40 50 60 70 80 90 100
Plot the function e-x/3sin(x) between
0≤x≤4π
 Create an x-array of 100 samples between
0 and 4π.
>>x=linspace(0,4*pi,100);

 Calculate sin(.) of the x-array


>>y=sin(x);

 Calculate e-x/3 of the x-array


>>y1=exp(-x/3);

 Multiply the arrays y and y1


>>y2=y*y1;
Plot the function e-x/3sin(x) between
0≤x≤4π
 Multiply the arrays y and y1 correctly
>>y2=y.*y1;

 Plot the y2-array 0.7

0.6

0.5

0.4

>>plot(y2) 0.3

0.2

0.1

-0.1

-0.2

-0.3
0 10 20 30 40 50 60 70 80 90 100
Additional References:

http://web.mit.edu/6.003/www/matlab.html
http://web.mit.edu/6.003/www/Labs/matlab
_6003.pdf
http://web.mit.edu/6.003/www/Labs/matlab
_tut.pdf
The End

You might also like