67% found this document useful (6 votes)
5K views

MCQ On MATLAB

The document contains multiple choice questions and answers related to MATLAB commands and functions. Some key points: - Questions cover topics like plotting graphs, matrix operations, conditional statements, loops, and other basic MATLAB concepts. - Answer options given for each question with one being the correct answer. - Wide range of MATLAB topics assessed including graphing, matrices, conditional logic, loops, string handling and more.

Uploaded by

Nishant Saxena
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
67% found this document useful (6 votes)
5K views

MCQ On MATLAB

The document contains multiple choice questions and answers related to MATLAB commands and functions. Some key points: - Questions cover topics like plotting graphs, matrix operations, conditional statements, loops, and other basic MATLAB concepts. - Answer options given for each question with one being the correct answer. - Wide range of MATLAB topics assessed including graphing, matrices, conditional logic, loops, string handling and more.

Uploaded by

Nishant Saxena
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 17

What is the output of the following code?

A=[0 0 0; 0 9 0; 1 2 3]; nnz[A]


A. 4
B. 5
C. 3
D. Error
ANSWER: D

The space located for the matrix generated from the spones command is _______
A. Same as a sparse matrix
B. Same as the original matrix
C. Same as an identity matrix
D. Double that of the sparse matrix
ANSWER: A

How can we smoothen the following graph of sin (t) and cos (t) into a circle?
A. reduce the gap between linearly spaced elements of the dependent variable t
B. reduce the gap between elements of the dependent variable t
C. increase the gap between linearly spaced elements of the dependent variable t
D. increase the gap between elements of the dependent variable t
ANSWER: A

Which command enables a title for the x-axis?


A. xlabel()
B. horilabel()
C. xlabel[]
D. no command
ANSWER: A

Which command gives a title to the graph plotted by MATLAB?


A. plot() generates the title itself
B. title()
C. hlabel()
D. heading()
ANSWER: B

Which command enables a title for the y-axis?


A. vertlabel()
B. ylabel()
C. ylabel[]
D. no command
ANSWER: B

How can several graphs for the same function be plotted on the same window?
A. Contour plots
B. Bode plots
C. 3-D plots
D. n-D plots
ANSWER: A

What is the output of the following command? meshgrid[x,y]


A. two x*y matrices
B. one x*y matrix
C. one y*x matrix
D. error
ANSWER: D

What is the output of the following code? t=0:0.001*pi:pi/2;


plot(t,sin(t),*);
A. An inverted sine curve
B. A sine curve
C. A point
D. Error
ANSWER: D

What is the slope of the sawtooth waveform generated by the sawtooth command?
A. 1/pi
B. pi
C. 1/(2*pi)
D. 2*pi
ANSWER: A

What is the period of the sawtooth() waveform which is generated by the sawtooth()
command?
A. 2*pi
B. pi*2
C. pi
D. 3*pi/2
ANSWER: A

What is the output of the following code? t=0:.001*pi:2*pi;


plot(cos(t),sin(t))
A. A circle
B. A straight line
C. A unit circle
D. A sinusoid
ANSWER: C

Which command is suitable to change the axes of the graph plotted?


A. axes
B. axis
C. yxaxes
D. no command
ANSWER: B

Which command can be used to generate multiple graphs in the same window?
A. hold on
B. wait
C. not possible without contour command
D. not possible
ANSWER: A

Which toolbox provides the plot command?


A. Symbolic Maths Toolbox
B. Signal Processing Toolbox
C. Engineering Toolbox
D. Functions
ANSWER: B

In a 2-d Plot, which command will make the axes of the graph same?
A. axis square
B. axis equals
C. axes square
D. axes equal
ANSWER: A
What is the output of the following code? title(�x^2+y^2=r^2�)
A. x2+y2 = r2
B. x^2+y^2 = r^2
C. Error
D. No such command
ANSWER: A

What is the default range used by the fplot command?


A. [-5,5]
B. (-5,5)
C. No default range
D. No such command
ANSWER: A

What is the purpose of the figure command?


A. Opens a blank window
B. Opens a blank window to draw graphs
C. Opens a window containing axes
D. Opens a window containing grid and axes
ANSWER: B

What is the range of co-ordinates obtained of the following code?


[x,y]=meshgrid(4)
A. 1:4 in x and y co-ordinates
B. 0:4 in x & y co-ordinates
C. only 4 in x and y co-ordinate
D. Error
ANSWER: C

What is the nature of z in surf(x,y,z)?


A. Integer
B. Vector
C. Matrix
D. String
ANSWER: C

Amongst multiple elseif and nested if, which would take less runtime?
A. multiple elseif
B. nested if
C. elseif
D. elseif & nested if
ANSWER: A

What is the output of the following code? if(x~=C. p=0; end


A. p=0
B. Output will be suppressed
C. Error
D. Cannot be determined
ANSWER: C

The end statement is given multiple times in _________


A. Multiple elseif
B. Nested if
C. elseif
D. if
ANSWER: B
What will happen if we don�t give an otherwise block to our switch structure?
A. Error
B. Infinitely demands a correct variable for case
C. Returns 0
D. Moves on to the next block
ANSWER: D

The if structure is a _________


A. Conditional structure
B. Logical structure
C. Nested structure
D. Biased structure
ANSWER: A

The switch-case structure is a _________


A. Conditional structure
B. Logical structure
C. Multidimensional structure
D. Hierarchical structure
ANSWER: B

The if-else structure does not allow ___________


A. Return statement
B. End statement
C. Endif statement
D. Break statement
ANSWER: D

What is the output of the following code? if((-10 &&00)||(20134 && 900)) ,
fprintf("%s","True."), else, fprintf("%s","False."), end
A. True
B. False
C. Error
D. Nan
ANSWER: A

We cannot use a ____ statement in the standalone if-else structure.


A. break
B. if-else
C. return
D. switch-case
ANSWER: A

What does the function all() do?


A. Returns 1 if all elements within it are 0
B. Returns 0 if all elements within it are 0
C. Returns 0 if all elements within it are non-zero
D. Returns 1 if all elements within it are non-zero
ANSWER: D

What is the output of the following code? i=0; for i=0:2 i=1;
end
A. Output is suppressed
B. Output shows 1 3 times
C. Output shows 1 2 times
D. Error
ANSWER: A

What is the output of the following code? i=0;for j=0:2 j=j-1


end
A. Infinite loop
B. -1
C. Output is suppressed
D. +1
ANSWER: B

What is the output of the following code? a=0;for j=0:2 j=j+1


end
A. Syntactical Error
B. 3
C. 2
D. Keyword Error
ANSWER: D

In nested loops, the continue statement exits the ____


A. current iteration
B. loop
C. inner
D. outer
ANSWER: A

In nested loops, the break statement, if present within a nested if the structure,
will exit the _______
A. Ongoing if structure
B. Entire loop
C. Ongoing loop
D. Entire if structure
ANSWER: B

In nested loops, the continue statement, if present within an if structure, will


exit the ____________
A. If structure
B. current iteration
C. entire loop
D. Error
ANSWER: B

In nested loops, the continue statement, if present within a nested if structure,


will exit the ____________
A. If structure
B. nested if structure
C. entire loop
D. present iteration
ANSWER: B

The for loop performs at least ___ iteration/s.


A. 1
B. not necessarily an iteration
C. 2
D. Error
ANSWER: B

Multiple graphs can be plotted, in the same window, if we use the ___ command in a
loop.
A. hold on
B. held on
C. hold off
D. not possible
ANSWER: A

The condition of a while loop cannot be given in ________


A. ()
B. []
C. {}
D. <>
ANSWER: C

What is the Full form of MATLAB?


A. Matrix Laboratory
B. Matrix Lab
C. Mathematics Laboratory
D. Mathematics Lab
ANSWER: A

What does display command does?


A. Display current value of command
B. Display previous value of command
C. Display nothing
D. Display last stored ANSWER
ANSWER: A

What is the output of the following code? disp(�%d�,Inf);


A. Inf
B. No such command
C. Error due to too many arguments
D. Syntactical error
ANSWER: C

What is the output of the following code? disp(� �,lola!� 2�)


A. �lola!� 2
B. � �lola!� 2�
C. �lola! 2�
D. Error due to multiple arguments
ANSWER: D

What is the output of the following code? evalc(�cos(0)�)


A. No such command
B. Error
C. 1
D. � ans=1 �
ANSWER: D

The feval command can evaluate __________


A. A single command
B. Multiple commands
C. Multiple functions
D. No such function exists
ANSWER: A

The eval command can evaluate __________


A. A single function
B. Only a single command
C. The function does not exist
D. Multiple commands
ANSWER: D

What is the output of the following code? feval[�round�,123.12]


A. 123
B. 123.12
C. 123.1
D. Error
ANSWER: D

Which function gets disabled while using evalc()?


A. diary
B. sin
C. inf
D. round
ANSWER: A

How much does the precision change while finding sin(x) using evalc and eval?
A. 10%
B. 2%
C. 20%
D. No change
ANSWER: D

2. To enter a value and change the course of working of a function while it is


working, we use the __________
A. dbstop
B. db
C. keyboard
D. enter
ANSWER: C

What does Matlab stand for?


A. Math Laboratory
B. Matrix Laboratory
C. Mathworks
D. Nothing
E. none of the above
ANSWER: B

Which of these is the way to access the rst element in a vector named v (assuming
there is at least one element in the vector)?
A. v(0)
B. v(1)
C. v
D. v(: , 0)
E. none of the above
ANSWER: B

Which of the following is used to see if two elements are equal in MATLAB?
A. !=
B. ==
C. isequal
D. =
E. none of the above
ANSWER: B

If vector = [1 2 3 4; 11 24 92 100; 345 65 90 1]. What will the value of a be equal


to if this code is entered into MATLAB >>[a b] = size (vector)?
A. 1 2 3 4
B. 12
C. 1
D. 4
E. 3
ANSWER: E

What is the value of ans that is printed when the following code is run:
isnumeric(32)
A. 1
B. 0
C. 32
D. yes
E. true
ANSWER: A

The output of cat=[�cat� �dog�] is


A. catdog
B. cat dog
C. cat&dog
D. CatDog
ANSWER: A

Which of the following is not a pre-dened variable in Matlab.


A. pi
B. inf
C. i
D. gravity
E. j
ANSWER: D

This Matlab command clears all data and variables stored in memory:
A. clc
B. clear
C. delete
D. deallocate
E. none of the above
ANSWER: B

5. Characters in Matlab are represented in their value in memory.


A. decimal
B. ASCII
C. hex
D. string
ANSWER: A

6. Which is these is not an aspect of a for/while loop:


A. update
B. initialization
C. runner
D. condition
E. all are aspects of loops
ANSWER: C

7. To better manage memory and prevent unnecessary memory allocations, Matlab uses:
A. vectors
B. scalars
C. matrix math
D. delayed copy
E. licenses
ANSWER: D

8. To print a newline in a fprintf statement, you must use the following escape
character:
A. \t
B. \nl
C. \nxt
D. \n
E. none of the above
ANSWER: D

9. In Matlab, this keyword immediately moves to the next iteration of the loop:
A. update
B. goto
C. continue
D. break
E. none of the above
ANSWER: C

32. To add a comment to the mle, the MATLAB command is


A. %
B. ;
C. comment(� �)
D. &
ANSWER: A

33. When used in the fprintf command, the %g is used as the


A. single character display
B. xed point display
C. string notation display
D. default number display
ANSWER: D

36. The clc command is used to


A. clear the command window
B. erase everything in the mle
C. clean the desktop
D. save the existing mle
ANSWER: A

37. The num2str command


A. converts a number to string
B. converts string to a number
C. concatenates numbers and strings
D. concatenates strings
ANSWER: A

Which one of the following is a legitimate variable names in


MATLAB?
A. 4var
B. tax-rate
C. exam1.1
D. _input
E. sin
ANSWER: E

Which of the following MATLAB calculations would result the


value 1?
A. 1+4/5
B. 6/2*3
C. 3^2/3*3
D. 1+2+3/1+2+3
E. None of the above
ANSWER: E

Which of the following MATLAB expression gives -1.


A. cos(180)
B. cosd(pi)
C. sind(3*pi/2)
D. sin(-pi/2)
E. None of the above
ANSWER: D

Which of the following expressions generates an evenly spaced


vector containing 15 values between 4 and 20.
A. x=linspace(4,15,20)
B. x=linspace(15,4,20)
C. x=linspace(4,20,15)
D. x=4:15:20
E. x=4:20:15
ANSWER:C

The difference between a function and a script is:


A. only a function file can be run from the command line
B. only a function requires inputs
C. only a script file can perform a series of
commands
D. functions cannot save variable values
E. function variable names only have meaning within the function,
whereas script variables are available to other programs
ANSWER: E

How would you start a debugger in MATLAB?


A. There is no M-file in MATLAB
B. Type edit in MATLAB and press Enter
C. Type debug in MATLAB and press Enter
D. Type M-file in MATLAB and press Enter
ANSWER: B

What is the extension of script files?


A. .m
B. .mat
C. .script
D. There is a nothing called script file
ANSWER: A

What is the basic difference between M-files and MAT-files?


A. There is no difference
B. MAT files are binary data files while m-files are ASCII text files
C. M files are binary data files while MAT-files are ASCII text files
D. There is no such thing as MAT files
ANSWER: B

What does the echo command do?


A. It echoes
B. It shows the comments present in Script files
C. It shows the commands and comments in MAT-files
D. It shows the commands and the comments in M-files
ANSWER: D

What will the following command do? Load m1


A. Load the script file named �m1�
B. Load the function file named �m1�
C. Load the m-file named �m1�
D. There is no Load command in MATLAB
ANSWER: C

What will the following command do? Save workspace


A. Saves the entire workspace as MAT file
B. Saves a variable named �workspace� as MAT file
C. Saves the entire workspace as m file
D. Saves a variable named �workspace� as m file
ANSWER: B

How do you create a function file in MATLAB?


A. Begin m-file with function definition
B. Begin script file with function definition
C. There is no such thing called function file
D. An m-file is only a function file
ANSWER: A

A student is repeatedly calling a function file but gets no output. She has checked
the file repeatedly so finally she asked her teacher about it. The teacher checked
everything and finds the error and gives her a scolding. What is a silly mistake?
A. She was calling the wrong function
B. She has placed a semicolon at the end of the line which computes the desired
values
C. She has called a .m file
D. She was calling a script file
ANSWER: B

A function is not returning values according to desired input values. What should
be the correction?
A. Include clear all at the beginning of function file
B. Include close all at the beginning of function file
C. Include echo on in the function file
D. Cannot be solved
ANSWER: A

How would you plot multiple graphs in MATLAB?


A. Using the hold function
B. Using the mplot function
C. Using the mstem function
D. It cannot be done in MATLAB
ANSWER: A
How do you show the program of an MAT file?
A. The program should contain the echo command
B. The program should contain the showprog command
C. The program should contain the diary command
D. The program cannot be shown while running a MEX file
ANSWER: D

What is the equivalent of subplot (1, 1, 1)?


A. subplot()
B. plot
C. It is not possible
D. axes
ANSWER: D

The command used to reflect the files from a disk into the workspace is _______
A. load
B. show
C. disp()
D. it is not possible
ANSWER: A

The format for 5 digit representation along with exponent is __________


A. short e
B. short g
C. short exp
D. 4 digit along with exponent value can be represented
ANSWER: A

What would be the output of the following code (in editor window)? A = [1 0 2]
; b = [3 0 7] ; c=a.*b;
A. [2 0 21]
B. [3 0 14]
C. [14 0 3]
D. [7 0 3]
ANSWER: B

What would be the output of the following code (in editor window)? a=1:5 ;
c=a.^2
A. [1 25]
B. [1 2 3 4 5]
C. [25 16 9 4 1]
D. [1 4 9 16 25]
ANSWER: D

What would be the output of the following code (in editor window)? A = [1 1
0 0] B = [1 ;2 ;3 ;4] C=A*B
A. 0
B. [1 0 0 0]
C. 3
D. [1 2 0 0]
ANSWER: C

What would be the output of the following code (in editor window)? A = [1 2;
3 4] C = A^2
A. [7 10; 15 22]
B. [1 4; 9 16]
C. [16 9; 4 1]
D. [22 15; 10 7]
ANSWER: A
If the result of our summation is Infinity, what will MATLAB show?
A. Infinity
B. Nan
C. Inf
D. Error
ANSWER: C

What is the error in the following? input(�pop�)


A. None
B. ��
C. Parentheses
D. No such command
ANSWER: B

What is the error in the following code? for i={1: 10}; p=a+1; end;
A. None
B. {}
C. The : operator
D. Cannot be determined
ANSWER: A

What is the output of the following code? limit((1 + 1/n)^n,n=Inf)


A. e
B. exp(1)
C. Syntactical Error
D. Cannot be determined
ANSWER: C

What is the output of the following code? A={1 2 3 4}


sum(A.
A. Error
B. 10
C. { 10 }
D. Logical Error
ANSWER: A

What is the output of the following code? mean({1 2 3})


A. 2
B. Logical Error
C. 1
D. Syntactical Error
ANSWER: D

What is the output of the following command? >> x={1 2 3}; >> t=[1 2
3]; >> plot(x,t)
A. plots a ramp function
B. plots r(t)-r(t-3)
C. Error due to plot
D. Error due to x
ANSWER: D

What is a linear system?


A. A system which follows homogeneity and additivity
B. A system which follows additivity
C. A system which follows homogeneity
D. Almost every system is linear
ANSWER: A

What is the output if the following code? if(eig(A.==eig(A�))


disp(�True�)
A. True
B. No output
C. False
D. Error
ANSWER: D

A student has to find a solution for a system of equations having three variables.
He has defined the coefficient matrix as C while the variable matrix as d. He
observes that the system is homogeneous. So, to find the solution, he must first
check
A. Consistency
B. Homogeneity
C. Heterogeneity
D. Linearity
ANSWER: A

The command to find the eigen vector of a matrix in matrix form is _____________
A. eig(a,matrix)
B. eig(a,�matrix�)
C. eigen(a,matr)
D. eig(A.
ANSWER: B

The nature of the eigen matrix displayed in MATLAB is ___________


A. Unsorted
B. Sorted
C. Sorted in Ascending order
D. Sorted in Descending order
ANSWER: A

Checking the linearity of a system, the first thing we need to check is whether the
system is __________
A. Homogeneous or not
B. Consistent or not
C. Superposition
D. Depends on the representation of the system
ANSWER: D

In MATLAB, how can we check linearity of systems represented by transfer function?


A. Check waveforms after superpostion
B. Compare rank of matrices
C. Go for Rouche�s Theorem
D. Intuition
ANSWER: A

How can we check in MATLAB if an electrical circuit is linear or not?


A. Check consistency
B. Superposition
C. Superposition via Simulink
D. Check homogeneity
ANSWER: C
What is the nature of storage of anything in MATLAB?
A. Stored as arrays
B. Stored as a data structure
C. Stored as a variable
D. Depends on nature of the input
ANSWER: A

What is the nature of the following variable, in MATLAB? A=[1 ,


�Poland�, �Nail polish�,�Hit�,�Ler�]
A. String
B. String-integer
C. Integer-string
D. Cannot be determined
ANSWER: A

What is the starting index of an array in MATLAB?


A. 1
B. 0
C. Depends on the class of array
D. Unknown
ANSWER: A

All data types are converted to ____ before mathematical operations.


A. Single
B. Double precision
C. Floating
D. Unsigned
ANSWER: B

What is the return type of angles in MATLAB?


A. Degrees
B. Radians
C. Radians & Degrees
D. Depends on the user
ANSWER: B

To represent only two digits after the decimal point, the format we use is ______
A. Long e
B. Short
C. Hex
D. Bank
ANSWER: D

How do we change the nature of the display of the numerical ANSWER?


A. Use the format command
B. Use the class command
C. MATLAB provides intuitive display
D. Not possible
ANSWER: A

Strings are stored in ____ variables.


A. Character
B. String
C. Stack
D. Array
ANSWER: A
What will be the output of the following code? ilaplace(1/syms p^2)
A. t
B. s
C. error
D. ilaplace is not present in MATLAB
ANSWER: C

How many expressions are there in the following mathematical relation?


a=sqrt(log(sqrt(x+y)))
A. 2
B. 3
C. 1
D. 4
ANSWER: B

How many functions are there in the following mathematical relation?


p=sin(pi*(log(x))
A. 2
B. 3
C. 1
D. 0
ANSWER: A

What are the minimum numbers of expressions which will be required to express a
mathematical relation?
A. At least 1
B. At least 2
C. At most 1
D. Depends on the number of variables
ANSWER: A

Is it possible to reduce the number of expressions in the following mathematical


relation? a=sin(pi*log(x))
A. Yes
B. No
C. Maybe
D. Impossible
ANSWER: A

Is it possible to reduce the number of functions in the following mathematical


relation? l=cos(2*pi*sin(n/x))
A. Yes
B. No
C. Maybe
D. Obviously
ANSWER: B

The teacher has given the assignment to find the sum of 2 numbers. But the code
should not contain the �+� operator. What is to be done?
A. Use a function
B. Add the values and print the sum directly
C. Use an expression
D. Cannot be done
ANSWER: A

What are mathematical expressions?


A. Any mathematical relation
B. Any mathematical operation
C. Any mathematical conversation
D. Any mathematical function
ANSWER: B

You might also like