MATLAB EXAM WITH COMPLETE SOLUTIONS
LATEST UPDATE
linspace - ANSWER Creates a linearly spaced vector:
example: (numbers from 2 to 4 in 3 digits equally spaced)
>>linspace(2,4,3)
234
logspace - ANSWER creates a logarithmically spaced vector
example:(numbers from 10^1 to 10^2 in 2 digits)
>>logspace(1,2,2)
10 100
rand(n) - ANSWER creates an nxn matrix of random reals
rand(n,m) - ANSWER creates an nxm matrix of random reals
randi([range],n,m) - ANSWER creates an nxm matrix of random integers in the range
zeros(n) - ANSWER returns an nxn matrix of all zeros
zeros(n,m) - ANSWER returns an nxm matrix of all zeros
ones(n) - ANSWER returns an nxn matrix of all ones
, ones(n,m) - ANSWER returns an nxm matrix of all ones
length - ANSWER returns the number of elements in a vector or the larger dimension for
matrix
size - ANSWER returns the number of rows and columns:
to capture the values in separate variables
[r, c] = size(mat)
r= 3
c=2
numel - ANSWER returns total number of elements in a vector or matrix
reshape (mymat,n,m) - ANSWER changes dimensions
example:
25
78
53
>> reshape(mymat,1,6)
ans =
275583
rot90 - ANSWER rotates a matrix 90 degrees counterclockwise
fliplr - ANSWER flips columns of matrix left to right
LATEST UPDATE
linspace - ANSWER Creates a linearly spaced vector:
example: (numbers from 2 to 4 in 3 digits equally spaced)
>>linspace(2,4,3)
234
logspace - ANSWER creates a logarithmically spaced vector
example:(numbers from 10^1 to 10^2 in 2 digits)
>>logspace(1,2,2)
10 100
rand(n) - ANSWER creates an nxn matrix of random reals
rand(n,m) - ANSWER creates an nxm matrix of random reals
randi([range],n,m) - ANSWER creates an nxm matrix of random integers in the range
zeros(n) - ANSWER returns an nxn matrix of all zeros
zeros(n,m) - ANSWER returns an nxm matrix of all zeros
ones(n) - ANSWER returns an nxn matrix of all ones
, ones(n,m) - ANSWER returns an nxm matrix of all ones
length - ANSWER returns the number of elements in a vector or the larger dimension for
matrix
size - ANSWER returns the number of rows and columns:
to capture the values in separate variables
[r, c] = size(mat)
r= 3
c=2
numel - ANSWER returns total number of elements in a vector or matrix
reshape (mymat,n,m) - ANSWER changes dimensions
example:
25
78
53
>> reshape(mymat,1,6)
ans =
275583
rot90 - ANSWER rotates a matrix 90 degrees counterclockwise
fliplr - ANSWER flips columns of matrix left to right