A Learning Portal from Recruitment India
What is the symbol used to evaluate the transpose of a vector?
“ ‘ ”
“ ^ ”
“ ~ ”
“ * ”
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)
Error due to an unmentioned value of a
Error due to Inf
Inf
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 ______
Signed numbers
Absolute numbers
Different
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 __________
sqrt[meansqr()]
sqrt(meansqr[])
sqrt[meansqr[]]
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)
NaN
1
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?
Matlab is an interpreted language thus it can be very slow.
Matlab codes are written in sentences and executed one by one
Being compiler independent makes Matlab more efficient and productive
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?
returns the power of the number
returns magnitude of a number.
returns the square root of a number.
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)
Error
A 3*2 sparse matrix
Memory is allocated for a 2*3 sparse matrix
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 !’)
Output suppressed
Yeah!
Error
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)
Returns a sparse matrix with the non-zeros replaced by random numbers
Returns a sparse matrix with the non-zeros replaced by fractions
Returns a sparse matrix with the zeros replaced by ones
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