Structural analysis Lec-2(07-02-2015)

Post on 14-Apr-2016

18 views 0 download

description

This is Structural analysis first lecture on Matlab.In which we understand how to design different programs on matlab.

Transcript of Structural analysis Lec-2(07-02-2015)

Structural Analysis

Lec-2

Contents Matrices Contd…

Matrix Indexing

Functions

1. Scalars

2. Vectors

Operators (Relation + Logical)

Plotting

Some useful Matrices

eye Identity Matrix

zeros A matrix of zeros

ones A matrix of ones

diag Creating or extracting diagonals

rand Random matrix

MATLAB Functions

Some Predefined Matrices Random matrices

Matrix of zeros

Matrix of ones

Identity matrix

Diagonal matrix

rand(3)

rand(3,4)

Zeros(2,3)

Ones(10,1)

Eye(3)

diag(3,2)

Matrix Indexing

Advanced Indexing

Submatrices A=rand(5)

A (2 , 3)

A(1,end)

A(1:2 , 2:3)

A(1 , :)

A(7)

% Define Matrix

Specifying an element

Specifying contiguous submatrix

To specify entire first row

=A(2,2)

Row

Column

Scalar Functions Some MATLAB functions applied to:

a. Scalars only

b. To all elements of vectors and matrices

A=rand(3,4)

b=sqrt(A)

C=cos(A)

Note: We may extract a submatrix and then use these

functions

Vector Functions Some MATLAB functions that operate on vectors only

Matrix Functions Important Matrix Functions

A=rand(3)

B=eig(A)

Sometimes such functions may use more than one

output function

[V,D]=eig(A)

Matrix whose columns are eigen vectors

Matrix whose diagonal values represents eigen values

Matrix Operations

Matrix Addition

Matrix Subtraction

Matrix mutiplication

C=A+B

C=A-B

C=A*D

Operators Some relation operators

Logical Operators

• The result is either 0 or 1.

• Zero…if it is false

• One…If it is true

Operators Precedence

Plotting For 2D plots

For 3D plots….use Plot3

Exercise