## MATLAB Questions and Answers Part-18

1. What is the output of the following code?
rand(2,’signed’)
a) A 2*2 matrix of signed data type
b) A 2 element vector of signed data type
c) A 2 element vector
d) Error

Explanation: The rand command cannot take signed as a user-defined data type. The available data types are single and double. Hence, this will generate an error.

2. What is the default return type of the rand command?
a) Single
b) Double
c) Signed
d) Unsigned

Explanation: The default return type of the rand command is double. It can be changed to single by giving single as a string input to the rand command.

3. The rand command is provided by the __________
a) Parallel Computing Toolbox
b) Signal Processing Toolbox
c) Symbolic Math Toolbox
d) Does not exist

Explanation: The parallel Computing Toolbox contains the rand command in MATLAB. The rest of the options are incorrect.

4. What is the output of the following code?
makedist(‘normal’)
a) Error
b) A normal distribution
c) A list of numbers selected randomly from the normal distribution
d) A normalized normal distribution

Explanation: If we don’t specify the mean and standard deviation of the normal distribution, the makedist command will generate a normal distribution which is normalized. This means the mean is 0 and a standard deviation is 1.

5. What is the output of the following code?
c=makedist(‘normal’);random(c)
a) An array of random numbers selected from the normalized normal distribution
b) Error due to makedist
c) A random number from the normalized normal distribution
d) Error due to random

Explanation: There is no error in the above code. Firstly, a normalized normal distribution would be generated. Thereafter, the random command would select a value from it and display it in the command window.

6. What is the attribute of sparse matrices?
a) sparse
b) double
c) vector
d) no attribute

Explanation: The attribute of a sparse matrix will be sparse while the class of the attribute is double, by default. Hence, sparse is correct.

7. What is the output of the following code?
sparse[m n]
a) A m*n all zero sparse matrix
b) A m*n sparse matrix
c) Error due to syntax
d) Error in the input

Explanation: There are two errors in the above code. MATLAB would return the syntactical error due to [] since there should be a parenthesis. There is an error in the input since there should be a ‘ , ‘ between m an n.

8. The nature of complex input taken by the sparse() command is ______________
a) Only Imaginary part
b) Only positive imaginary part
c) Only negative real part
d) All of the mentioned

Explanation: The sparse() command takes all kind of complex inputs. It is not biased by default.

9. Which of the following can be the space taken up by a sparse matrix?
a) .25 megabytes
b) 600 megabytes
c) .5 GB
d) 450 megabytes