Sunday, 31 July 2016

MATLAB Programming 42 - Some array functions (2)


Special Arrays in MATLAB


The eye() function creates an identity matrix.


For example:


eye(4)

MATLAB will execute the above statement and return the following result:


ans =
1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1

The rand() function creates an array of uniformly distributed random numbers on (0,1):


For example:


rand(3, 5)

MATLAB will execute the above statement and return the following result:


ans =
0.8147  0.9134  0.2785  0.9649  0.9572
0.9058  0.6324  0.5469  0.1576  0.4854
0.1270  0.0975  0.9575  0.9706  0.8003

No comments:

Post a Comment