Professional Documents
Culture Documents
Matlab Screen
◼ Command Window
❑ type commands
◼ Current Directory
❑ View folders and m-files
◼ Workspace
❑ View program variables
❑ Double click on a variable
to see it in the Array Editor
◼ Command History
❑ view past commands
❑ save a whole session
using diary
Matlab’s Workspace
◼ x = linspace(-pi,pi,10); % creates 10
linearly-spaced elements from –pi to pi.
◼ logspace is similar.
◼ A = [1 2 3; 4 5 6]; % creates 2x3 matrix
◼ A(1,2) % the element in row 1, column 2.
◼ A(:,2) % the second column.
◼ A(2,:) % the second row.
Arrays and Matrices (3)
x =
1 2 5 1
>> y=[-1; 2; 0; 8]
y =
-1
2
0
8
◼ a matrix >>x = [1 2 3; 5 1 4; 3 2 -1]
x =
1 2 3
5 1 4
3 2 -1
Array, Matrix
◼ transpose z = x’ z =
1
2
5
1
Generating Vectors from functions
◼ zeros(m,n) mxn matrix of zeros A = zeros(1,3)
A =
0 0 0
Given A and B:
◼ Inv(A): inverse of A
◼ Rank(A): rank of matrix A
◼ A’: transpose of A
◼ Det(A): determinant
◼ V= eig(A): eigenvalue vector of A
❑ [V,D] = eig(A) produces matrices of eigenvalues (D)
and eigenvectors (V) of matrix A, so that A*V = V*D
16
Elementary Math Function
◼ Abs(), sign()
❑ Sign(A) = A./abs(A)
◼ Sin(), cos(), asin(), acos()
◼ Exp(), log(), log10()
◼ Ceil(), floor()
◼ Sqrt()
◼ Real(), imag()
17
Save/Load Data
◼ Save fname
❑ Save all workspace data into fname.mat
◼ Load fname
❑ Load fname
18
Online Tutorials
19