Professional Documents
Culture Documents
Saji
Saji
Saji
EYE(M,N) or EYE([M,N]) is an M-by-N matrix with 1's on the diagonal and zeros elsewhere.
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');
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
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
a ans m t v w x ys z
>> pwd
ans =
C:\Users\SUKKURIBA\Documents\MATLAB
>> 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.
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=
m=
1 2 4
2 3 6
3 1 5
1.>> v(2)
ans =
2.>> sum = v + w
sum =
7 15 14 W.
diff =
1 -1 -4
vw =
9 together.
ans =
3 whole row.
Explanation= here we are taking the elements from 2nd to 6th from the
6.>> v'
ans =
2 4 7 5
z=
1 1
0 0
ans =
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
ans =
1 2 4
ans =
3 1 5
ans =
1 2 4
3 1 5
ans =
2 4
3 6
1 5
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=
ans =
0 0 0
4 0 0
0 7 0
0 0 5
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
a=
Explanation= here we set element value of 1st and 3rd column with 0 .
28.>> a(1,2)=100
a=
0 100
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.