Thursday, May 14, 2015

Hermitian of a complex matrix using MatLab

Herimitian of a complex matrix can be obtained by taking the conjugate transpose of that matrix

Example Program :


%% Generate a complex matrix

A=[i 2 3; 3i+3 3 1+i; i i 7]

%% Hermitian of matrix

B=A'

Conversion of general matrix to logical array using MatLab

If the element is non zero then it will be manipulated as logical one. else it is taken as zero.


Example Program:


%% Generate a Matrix

A=[3 5 6; 4.5 0 6;0 0 1.3]

%% Convert the matrix into the logical array

B=logical (A)

Wednesday, May 13, 2015

Check the class of the variables in MatLab

The variables may be of type float, Int, char etc.  

Example Program : 

%% Check the class of the variables
%% Assign float value to the A

A = 3.055;

%% Display the class of A
class(A)

%% Assign the Int value to B

B=3

%% Display the Class of B
class(B)

%% Assign the char value to c

C='hello'

%% Display the Class of c
class(C)

Data Type check of stored variables in Matlab work space

'whos' command will display the details of all variables in the work space

Example Program:

%% Generate a matrix A

A=[5 4 3; 2 6 3; 8 9 5];

%Get the details about the A

whos;

Toeplitz matrix generation using Matlab

Toeplitz matrix is a matrix in which each descending diagonal from left to right is constant  

Example Program :

%Generate toeplitz matrix of 3x3 consisting of elements 2 5 6

t = toeplitz([2 5 6])

Tuesday, May 12, 2015

Generating Vandermonde Matrix in MatLab

The Vandermonde matrix is a nxn matrix whose row elements are in the form of geometric progression. This matrix has full rank .

Example program :

%% Generate Vandermonde matrix

%% Fundamental Elements 

v = 1:.5:2


A = vander(v)


Logical Array in Matlab

The key word 'true' in MatLab is evaluated to '1', 'false' evaluated to '0'.


Example Program :

%%Create logical array's

x=[true false]