Saji

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 16

>> help eye EYE Identity matrix. EYE(N) is the N-by-N identity matrix.

EYE(M,N) or EYE([M,N]) is an M-by-N matrix with 1's on the diagonal and zeros elsewhere.

EYE(SIZE(A)) is the same size as A.

EYE with no arguments is the scalar 1.

EYE(M,N,CLASSNAME) or EYE([M,N],CLASSNAME) is an M-by-N matrix with 1's of class CLASSNAME on the diagonal and zeros elsewhere.

Note: The size inputs M and N should be nonnegative integers. Negative integers are treated as 0.

Example: x = eye(2,3,'int8');

See also speye, ones, zeros, rand, randn.

help whos

WHOS List current variables, long form. WHOS is a long form of WHO. It lists all the variables in the current workspace, together with information about their size, bytes, class, etc.

In a nested function, variables are grouped into those in the nested function and those in each of the containing functions, each group separated by a line of dashes. In nested functions and in functions containing nested functions, even uninitialized variables are listed.

WHOS GLOBAL lists the variables in the global workspace. WHOS -FILE FILENAME lists the variables in the specified .MAT file. WHOS ... VAR1 VAR2 restricts the display to the variables specified.

The wildcard character '*' can be used to display variables that match a pattern. For instance, WHOS A* finds all variables in the current workspace that start with A.

WHOS -REGEXP PAT1 PAT2 can be used to display all variables matching the specified patterns using regular expressions. For more information on using regular expressions, type "doc regexp" at the command prompt.

Use the functional form of WHOS, such as WHOS('-file',FILE,V1,V2), when the filename or variable names are stored in strings.

S = WHOS(...) returns a structure with the fields: name -- variable name size -- variable size bytes -- number of bytes allocated for the array class -- class of variable global -- logical indicating whether variable is global sparse -- logical indicating whether value is sparse complex -- logical indicating whether value is complex nesting -- struct with the following two fields: function -- name of function where variable is defined level -- nesting level of the function You must use the functional form of WHOS when there is an output argument.

>> help who WHO List current variables. WHO lists the variables in the current workspace.

In a nested function, variables are grouped into those in the nested function and those in each of the containing functions. WHO displays only the variables names, not the function to which each variable belongs. For this information, use WHOS. In nested functions and

in functions containing nested functions, even unassigned variables are listed.

WHOS lists more information about each variable. WHO GLOBAL and WHOS GLOBAL list the variables in the global workspace. WHO -FILE FILENAME lists the variables in the specified .MAT file.

S = WHO(...) returns a cell array containing the names of the variables in the workspace or file. You must use the functional form of WHO when there is an output argument.

>> who

Your variables are:

a ans m t v w x ys z

>> pwd

ans =

C:\Users\SUKKURIBA\Documents\MATLAB

>> help pwd PWD Show (print) current working directory.

PWD displays the current working directory.

S = PWD returns the current directory in the string S.

>> hold Current plot held >> help hold HOLD Hold current graph HOLD ON holds the current plot and all axis properties so that subsequent graphing commands add to the existing graph. HOLD OFF returns to the default mode whereby PLOT commands erase the previous plots and reset all axis properties before drawing new plots. HOLD, by itself, toggles the hold state. HOLD does not affect axis autoranging properties.

HOLD ALL holds the plot and the current color and linestyle so that subsequent plotting commands will not reset the color and linestyle.

HOLD(AX,...) applies the command to the Axes object AX.

Algorithm note: HOLD ON sets the NextPlot property of the current figure and axes to "add".

HOLD OFF sets the NextPlot property of the current axes to "replace".

FUNCTIONS

>> v=[2 4 7 5], w=[1 3 8 9];

v=

>> >> m=[1 2 3 231 4 6 5]

m=

1 2 4

2 3 6

3 1 5

1.>> v(2)

ans =

Explanation= here we have taken 2nd element of V variable s row.

2.>> sum = v + w

sum =

7 15 14 W.

Explanation= here we have added the elements of V and


3. >> diff = v -w

diff =

1 -1 -4

Explanation=here we have subtracted the elements of V with W.


4. >> vw=[v w]

vw =

9 together.

explanation= here we have set the elements of V and W


5.>> vw(2:6)

ans =

3 whole row.

Explanation= here we are taking the elements from 2nd to 6th from the
6.>> v'

ans =

2 4 7 5

Explanation= here we have inverted the elements of row into column.


7.>> z=[1;1;0;0]

z=

1 1

0 0

Explanation=here we have created an array of z.


8.>> z'

ans =

Explanation=here we have inverted the elements of z from column to row.


9.>> z*v

ans =

2 2 0 0

4 4 0 0

7 7 0 0

5 5 0 0

Explanation=here we have multiplied the whole row of V with each elements of column of z.
10.>> [v ; w]

ans =

2 1

4 3

7 8

5 9

Explanation=here we have set the elements of V and elements of W together but separating with
(;) for making 1st row of V and 2nd row for W . 11.>> v*z

ans =

Explanation= here we have multiplied elements of v with elements of z ,resultant elements would
be 2 and 4 , 6 is final added result of 2 and 4. 12.>> [z;v']

ans =

1 1 0 0 2 4 7 5

Explanation=here we have kept the column of z with row of v which is inverted to column.
13.>> z+v'

ans =

3 5 7 5

Explanation= here we have added the elements of column z with column of v which is inverted
form of row v. 14.>> m(1,1)

ans =

Explanation=here we have called the elemenys of m which is at first row and first column.
15.>> m(1:2,1:2)

ans =

1 2

2 3 and 1st and 2nd column, by specifieng the rang

Explanation= here we have called 1st and 2nd row


with (:) sign. 16.>> m(:,1)

ans =

1 2 4

Explanation=here we have called all rows anf 1st column of matrix M.


17.>> m(:,end)

ans =

3 1 5

Explamnation=here we are calling the last column with all rows.


18.>> m(:,[1 3])

ans =

1 2 4

3 1 5

Explanation=here we are calling all rows of 1st and 3rd column.


19.>> m(:,:)

ans =

2 4

3 6

1 5

Explanation= here we are calling all rows and all columns.


20.>> m(:,2)=[]

m=

1 2 4

3 1 5

Explanation= here we have set all rows of 2nd column to null(0r deleted) and showing remaining
column and rows. 21.>> fliplr(m)

ans =

3 1 5

1 2 4

Explanation= here we have flipped the elements of left column to the elements of right column.
>> flipud(m)

ans =

2 1

1 3

Explanation= here we have flipped the elements form up to down and down to up.
22.>> m(:)

ans =

1 2 4 3 1 5

Explanation= here we have set values of m in column form by using (:) sign.
>> m=m(:)'

m=

Explanation= here we have inverted the elements of M form column to row.


23.>> diag(v)

ans =

0 0 0

4 0 0

0 7 0

0 0 5

Explanation= here we have set the elements of V in diagonal form.


24.>> diag(m)

ans =

1 0 0 0 0 0

0 2 0 0 0 0

0 0 4 0 0 0

0 0 0 3 0 0

0 0 0 0 1 0

0 0 0 0 0 5

Explanation= here we have set the elements of M in diagonal form.


25.>> a=1:5;

Explanation=here we have set the elements of A ranges from 1 to 5.


26.>> a(2)=6;

Explanation= here we have set the 2nd element of A with value 6.


27.>> a([1 3])=0

a=

Explanation= here we set element value of 1st and 3rd column with 0 .
28.>> a(1,2)=100

a=

0 100

5 1st row and 2nd column with value 100.

Explanation= here we have set the element at


>> a(3)=[]

a=

0 100

Explanation= here we have set the 3rd column with null value or deleted the 3rd element.
>> a([1 4])=[]

a=

100

Explanation= here we have set the values of 1st and 4th column with null value or deleted them.

You might also like