18
INTRODUCTION TO MATLAB

Matlab New

Embed Size (px)

DESCRIPTION

Lecture Presentation

Citation preview

PROGRAMMING (C++)

INTRODUCTIONTO MATLAB

INTRODUCTION

Matlab- which stands for MATrix LABoratory, is a high-performance language for technical computing. It integrates computation, visualization, and programming in an easy-to-useenvironment where problems and solutions are expressed in familiarmathematical notation.

APPLICATION OF MATLABMath and computationAlgorithm developmentData acquisitionModeling, simulation, and prototypingData analysis, exploration, and visualizationScientific and engineering graphicsApplication development, including graphical user interface buildingMATLAB SYSTEM Development Environment.The MATLAB Mathematical Function Library.The MATLAB Language.Graphics.The MATLAB Application Program Interface (API).MATLAB INTERFACE

Command Windowtype commands

Current DirectoryView folders and m-files

WorkspaceView program variablesDouble click on a variable to see it in the Array Editor

Command Historyview past commandssave a whole session using diary

VariablesNo need for types. i.e.,

All variables are created with double precision unless specified and they are matrices.

int a;double b;float c;Example:>>x=5;>>x1=2;Array, Matrixa vectorx = [1 2 5 1]x = 1 2 5 1

a matrixz = [1 2 3; 5 1 4; 3 2 -1]

z = 1 2 3 5 1 4 3 2 -1

transposey = x y = 1 2 5 1

Long Array, Matrix t =1:10 t = 1 2 3 4 5 6 7 8 9 10k =2:-0.5:-1 k = 2 1.5 1 0.5 0 -0.5 -1

B = [1:4; 5:8]B = 1 2 3 4 5 6 7 8

Generating Vectors from functions

Matrix Index

Operators (arithmetic)

Matrices Operations

Given A and B:AdditionSubtractionProductTransposeOperators (Element by Element)

Operators (Element by Element)a = ab cd

b = ef gh

a.*b = aebf

cgdh

Basic Matrix OperationsInv(A): inverse of ARank(A): rank of matrix AA: transpose of ADet(A): determinantV= eig(A): eigenvalue vector of ASize(A): return [m n]Length(A): length of a vectorLength(A) = max(size(A))

Basic Matrix OperationsB = A(2:4,3:5)B is the subset of A from row 2 to row 4, column 3 to column 5A(:, 2)=[]Delete second columnfind(condition) - Returns indexes of As elements that satisfies the condition.A = [1 2; 3 4], I = find(A vertcat CAT arguments dimensions are not consistent.