A Learning Portal from Recruitment India

What is the symbol used to evaluate the transpose of a vector?

A.

“ ‘ ”

B.

“ ^ ”

C.

“ ~ ”

D.

“ * ”

Answer with explanation

Answer: Option AExplanation

It is pre-defined in MATLAB that if we want to find the transpose of a vector, we will have to use the “ ‘ ” symbol following the vector or the vector name. “ ^ ” is used to raise the power of a variable while “ * ” is used for multiplication purposes.

Workspace

What is the output of the following code shown?

syms a k; symsum(a^k, 0, Inf)

A.

Error due to an unmentioned value of a

B.

Error due to Inf

C.

Inf

D.

1/1-a

Answer with explanation

Answer: Option DExplanation

The correct answer is 1/1-a

MATLAB will return an answer intuitively while considering symbolic summations. Here, MATLAB will return an answer which is plausible to a condition.

Workspace

The result of cumsum([1,2,3]) and sum([3,3]) are ______

A.

Signed numbers

B.

Absolute numbers

C.

Different

D.

Same

Answer with explanation

Answer: Option CExplanation

The correct answer is Different

The result of cumsum([1 2 3]) is 1,3,6 i.e the result is a row vector having output after adding up each element cumulatively while the result of sum([3 3]) is only 6

Workspace

The function to find the R.M.S value is __________

A.

sqrt[meansqr()]

B.

sqrt(meansqr[])

C.

sqrt[meansqr[]]

D.

sqrt(meansqr())

Answer with explanation

Answer: Option DExplanation

The correct syntax of the function which performs the mean square of a set of elements is meansqr(). The correct syntax of the function which returns the square root of a number is sqrt()

Workspace

What is the output of the following code?

prod(1:NaN)

A.

NaN

B.

1

C.

0

D.

Error

Answer with explanation

Answer: Option AExplanation

The correct answer is NaN

The range, we have defined, from 1 consists of NaN. The product of any number with NaN will give an output NaN

Workspace

Which of the following is the disadvantage of Matlab?

A.

Matlab is an interpreted language thus it can be very slow.

B.

Matlab codes are written in sentences and executed one by one

C.

Being compiler independent makes Matlab more efficient and productive

D.

Matlab is a fourth-generation high-level language

Answer with explanation

Answer: Option AExplanation

The correct answer is Matlab is an interpreted language thus it can be very slow.

Workspace

What is the use of abs function in Matlab?

A.

returns the power of the number

B.

returns magnitude of a number.

C.

returns the square root of a number.

D.

None of these

Answer with explanation

Answer: Option BExplanation

The correct answer is abs function in Matlab is used to return magnitude of a number

Workspace

What is the output of the following command?

spalloc(2,3, 7)

A.

Error

B.

A 3*2 sparse matrix

C.

Memory is allocated for a 2*3 sparse matrix

D.

A 2*3 sparse matrix

Answer with explanation

Answer: Option CExplanation

The correct answer is Memory is allocated for a 2*3 sparse matrix

The scallops command will allocate memory for the 2*3 matrix due to the above code. There will be no error.

Workspace

What is the output of the following code?

A=[1 2 3; 4 5 6; 7 8 9];if( nzmax(A)==nzmax(spones(A) ) disp(‘Yeah !’)

A.

Output suppressed

B.

Yeah!

C.

Error

D.

No output

Answer with explanation

Answer: Option DExplanation

The correct answer is No output

There is no error in the above code. Since, if the command is not ended, no output will be generated. If the if command was ended, the output would’ve been Yeah !.

Workspace

What is the output of the following code?

A=[1 2 3; 32 23 26; 0 0 0]; spones(A)

A.

Returns a sparse matrix with the non-zeros replaced by random numbers

B.

Returns a sparse matrix with the non-zeros replaced by fractions

C.

Returns a sparse matrix with the zeros replaced by ones

D.

Returns a sparse matrix with the non-zeros replaced by normally distributed random numbers

Answer with explanation

Answer: Option CExplanation

The spines command returns a sparse matrix with ones replaced by zeros. Hence, Returns a sparse matrix with the zeros replaced by ones that are correct while the rest of the options are incorrect.

Output:

and =

(1,1) 1

(2,1) 1

(1,2) 1

(2,2) 1

(1,3) 1

(2,3) 1

Workspace

Correct Answer 👍

Wrong Answer 👎