Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

1.

The help command works only for a pre-defined function in MATLAB.(a) True(b) FalseThe question was asked in final exam.The query is from Presenting Results topic in portion Interacting with MATLAB of MATLAB

Answer»

The CORRECT choice is (a) True

The best explanation: The help command will only show the nature of functions of any command which is already existing in the MATLAB directory. If we WANT to show the PURPOSE of our written function, we have to ADD comments in our m-file and then enter the echo command.

2.

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 fileI got this question in an international level competition.My enquiry is from M-Files topic in portion Interacting with MATLAB of MATLAB

Answer»

Right answer is (b) She has placed a semicolon at the end of the line which computes the desired values

To explain: If we write a function file, we should not put a semicolon at the line which computes a value. This will LEAD to the PASSING of cursor to the next line after the function is IMPLEMENTED without SHOWING any output. So it was good that the teacher SCOLDED her.

3.

A for-loop can have multiple index values.(a) True(b) FalseI had been asked this question during an online exam.This key question is from Loops topic in division Interacting with MATLAB of MATLAB

Answer»

Correct answer is (a) True

For EXPLANATION: A for-loop has a SINGLE INDEX. But it has multiple index-values during successive iterations.

4.

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 EnterThis question was addressed to me during an interview.This intriguing question comes from M-Files topic in division Interacting with MATLAB of MATLAB

Answer»

The correct answer is (b) Type EDIT in MATLAB and press Enter

The best explanation: M-files are simple text files containing MATLAB programs. These can be used to run complex programs EASILY. In MATLAB, we can type edit to begin WRITING in Editor/Debugger MODE. Typing debug or M-file won’t do any good.

5.

MATLAB allows modelling of different control systems using ___________(a) Simulink(b) Control System Toolbox(c) Not available in MATLAB as of yet(d) ezplotThis question was addressed to me at a job interview.My question is based upon The MATLAB Interface in portion Interacting with MATLAB of MATLAB

Answer»

Correct answer is (a) Simulink

The best I can EXPLAIN: Simulink is a separate PACKAGE which is present in MATLAB. It helps to model and ANALYZE a CONTROL system which makes MATLAB a very powerful tool for simulating dynamic systems.

6.

How will you return to execution from debugging mode?(a) Use the dbcont command(b) Use the return command(c) Use the dbcont & return command(d) Use the keyboard commandI have been asked this question in an internship interview.Question is taken from Fine Tuning topic in portion Interacting with MATLAB of MATLAB

Answer»

The CORRECT option is (c) Use the dbcont & return command

Easy explanation: While debugging, the user can choose to insert a set of instruction to change the nature of the already WRITTEN program. To return to CONTINUE EXECUTION, the user can enter either dbcont or the return command.

7.

The function definition is shown when we use the look for the command.(a) True(b) FalseI got this question in unit test.This question is from Fine Tuning in chapter Interacting with MATLAB of MATLAB

Answer»

Correct option is (B) False

To elaborate: The look for command shows the H1 line USED in a function. The look for command will DESCRIBE only inbuilt functions and not user-defined function. The H1 line is comment line just after the function definition so the look for command does not return the function definition.

8.

To stop execution, press _____(a) Ctrl+C(b) Use pause command(c) Use end command(d) Use keyboard commandThe question was asked in quiz.My question is based upon Fine Tuning topic in portion Interacting with MATLAB of MATLAB

Answer»

The correct answer is (a) Ctrl+C

The explanation is: The pause/keyboard COMMAND is used to suspend execution for a CERTAIN time. If we press Ctrl+C, execution will be completely STOPPED. The end command is used to end LOOPS of any KIND.

9.

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 representedI got this question in an interview for job.The query is from Presenting Results topic in portion Interacting with MATLAB of MATLAB

Answer» CORRECT option is (a) short e

Explanation: The short e format is used to represent a RESULT with 5 digits and an exponent term. Now, this is pre-defined in MATLAB. Short g and short exp are not PRESENT in MATLAB. We cannot use a representation of 4 digits and an exponent as it is not defined in MATLAB, as of YET.
10.

How do we break from an infinite loop without keeping a break statement within the loop?(a) Press Ctrl+C(b) Press Ctrl+Z(c) Loop won’t be terminated(d) Press Ctrl+XThe question was asked during an online interview.My question comes from Loops in chapter Interacting with MATLAB of MATLAB

Answer»

Right answer is (a) Press Ctrl+C

Best EXPLANATION: If we begin an infinite LOOP, by choice or as a silly mistake, we can TERMINATE the loop manually if we forget to introduce a break STATEMENT as necessary. We can choose to press Ctrl + C and the loop will get terminated at the same INSTANT.

11.

The command used to reflect the files from a disk into the workspace is _______(a) load(b) show(c) disp()(d) it is not possibleThis question was addressed to me during a job interview.The above asked question is from Presenting Results topic in chapter Interacting with MATLAB of MATLAB

Answer» RIGHT ANSWER is (a) LOAD

For explanation I WOULD SAY: The load function is pre-defined in MATLAB. It is used to load variables and/or data from the disk to the workspace.
12.

There can be multiple decision variables for while loop.(a) True(b) FalseThe question was asked by my college director while I was bunking the class.My question comes from Loops topic in section Interacting with MATLAB of MATLAB

Answer»

Correct option is (a) True

To EXPLAIN: We can PROVIDE MULTIPLE CONDITIONS to END a while loop. The conditions can be different so we can have multiple decision variables for while loop.

13.

A break statement will leave the outer loop.(a) True(b) FalseThe question was posed to me in an interview.My doubt stems from Loops topic in chapter Interacting with MATLAB of MATLAB

Answer»

Right OPTION is (B) False

Explanation: In case of nested for-loops or while-loops, the break statement will remove CONTROL only form the loop where it was INVOKED as a command. It won’t come out from the OUTER loop.

14.

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 solvedI had been asked this question during an online exam.I'd like to ask this question from M-Files in division Interacting with MATLAB of MATLAB

Answer»

Right answer is (a) Include clear all at the BEGINNING of function file

Best EXPLANATION: EVEN though the variables defined within a function are LOCAL variables, they might get affected due to the previous usage. So while execution of the same function, the user might get a different answer. Thus it is ADVISED to include clear all to remove all previous definitions of variables. The command ‘close all’ is used to clear the previously created graphs.

15.

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 fileThe question was posed to me during an internship interview.I would like to ask this question from M-Files in division Interacting with MATLAB of MATLAB

Answer» RIGHT option is (a) Begin m-FILE with function definition

For explanation: If an m-file starts with a function definition, it becomes a function file. This file can be called to generate a desired output multiple times. As MATLAB allows the MAKING of such files, complicated big programs can be broken down to simplify the nature of the ENTIRE MATLAB program.
16.

How would you expect to see exponential inter-relation in a logarithmic scale?(a) A straight line(b) A curved line(c) Depends on the exponent(d) Depends on the log scaleThe question was posed to me by my school principal while I was bunking the class.Enquiry is from Fine Tuning in division Interacting with MATLAB of MATLAB

Answer»

Right answer is (a) A straight line

The best I can explain: The EXPONENTIAL inter-relation will appear as a straight line in a log scale. This is because LOGARITHMIC scale and exponential NATURE follow a linear RELATIONSHIP. If there are no other terms than EXPONENTIALS in the expression, the graph will be a linear one.

17.

It is not possible to store graphs as MAT-file.(a) True(b) FalseThis question was posed to me in an online quiz.This is a very interesting question from Presenting Results topic in chapter Interacting with MATLAB of MATLAB

Answer»

Right CHOICE is (a) True

To elaborate: MAT files save data from the workspace. A graph, plotted among different variables, cannot be stored in MATLAB SINCE MAT-files are files USED to STORE values from the workspace.

18.

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 fileThis question was addressed to me during a job interview.My question is taken from Presenting Results topic in chapter Interacting with MATLAB of MATLAB

Answer»

The correct CHOICE is (d) The program cannot be shown while RUNNING a MEX FILE

Easy explanation: MEX files are not M-files. They are binary files which store the values of variables present in the WORKSPACE. So there is no QUESTION of showing the program of a MAT file.

19.

MEX files work on JAVA.(a) True(b) FalseThe question was posed to me in an online quiz.This key question is from M-Files in chapter Interacting with MATLAB of MATLAB

Answer»

The CORRECT answer is (B) False

Explanation: MEX files are files WRITTEN in C language. They can be integrated with MATLAB. They won’t work on JAVA.

20.

There will be a problem in computing the logarithm of a negative number.(a) True(b) FalseThe question was posed to me at a job interview.The question is from Fine Tuning in division Interacting with MATLAB of MATLAB

Answer»

Right choice is (B) False

The best I can EXPLAIN: While TRYING to compute a value for the LOGARITHM of a negative number, MATLAB will return an imaginary value. We can do problems which need to compute the logarithm of a negative number.

21.

We cannot plot a discrete and continuous relationship in the same graph.(a) True(b) FalseThe question was asked in an online interview.The above asked question is from Presenting Results topic in portion Interacting with MATLAB of MATLAB

Answer»

Right choice is (b) False

The best explanation: We can PLOT a DISCRETE and continuous relationship in the same GRAPH. We have to use the hold command and change the scaling of the variables a BIT if at all needed, so that the discrete and continuous relationship LOOKS prominent enough in the same graph. We have to use the hold command efficiently.

22.

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-filesI have been asked this question in an online interview.Query is from M-Files in division Interacting with MATLAB of MATLAB

Answer»

The CORRECT OPTION is (d) It shows the COMMANDS and the comments in M-files

For explanation: The ECHO COMMAND is a pre-defined function in MATLAB. If it is present in an m-file, the command will help to show the commands and comments present in the m-file when the m-file is called in the command window.

23.

How to stop the execution of a chain of commands?(a) Press Ctrl +c(b) Cannot be stopped(c) Only usage of debugging mode is possible in MATLAB(d) QuitThis question was addressed to me in examination.This intriguing question originated from The MATLAB Interface in chapter Interacting with MATLAB of MATLAB

Answer»

The CORRECT option is (a) Press Ctrl +c

The explanation is: It may so happen that we want to PAUSE the execution of a set of commands at a certain point. We only need to press Ctrl and C together to pause it. On the other HAND, quit causes the MATLAB software to shut down. Debugging modes are ALSO AVAILABLE in MATLAB.

24.

What are the difference between the ‘help’ and the ‘look for’ command?(a) No difference(b) Syntactical difference(c) Help returns the entire set while look for returns specific commands(d) Help returns all the toolbox while look for returns a single toolboxThis question was posed to me in exam.My question is taken from The MATLAB Interface in portion Interacting with MATLAB of MATLAB

Answer»

The correct option is (c) Help returns the entire SET while look for returns specific commands

The best I can explain: The ‘help’ command is used to return all the commands SURROUNDING a particular toolbox name ENTERED ALONG with it. The ‘look for’ command is used to return a particular function or set of functions WHOSE name matches with the keyword entered in along with the ‘look for’ command.

25.

The function to close the windows containing graphs generated from MATLAB is __________(a) close all(b) close graphs(c) delete graphs(d) end allI had been asked this question by my school principal while I was bunking the class.This intriguing question originated from The MATLAB Interface in chapter Interacting with MATLAB of MATLAB

Answer»

The correct choice is (a) close all

For EXPLANATION I would say: The command close all is a pre-defined function in MATLAB. When it is CALLED, MATLAB will automatically shut down the separate WINDOWS that have been OPENED to view graphs separately. The rest of the options are WRONG.

26.

What are MEX files in MATLAB?(a) No such thing as MEX files(b) Helps to analyse commands in MATLAB(c) Allows the user to combine C source files with Matlab files(d) Same as MAT filesI have been asked this question by my college director while I was bunking the class.Question is taken from The MATLAB Interface topic in portion Interacting with MATLAB of MATLAB

Answer»

The correct CHOICE is (c) Allows the user to COMBINE C SOURCE files with MATLAB files

The explanation: MEX files are one of the kinds of file MODES available in MATLAB. They are saved with a .mex extension. These files help in the association of C source files into the programs written in MATLAB.

27.

Global variables must be mentioned _____ an M-file.(a) at the top in(b) anywhere in(c) out of the(d) there is nothing called global variablesThe question was posed to me by my school principal while I was bunking the class.I would like to ask this question from Fine Tuning in division Interacting with MATLAB of MATLAB

Answer»

Right choice is (a) at the top in

The BEST explanation: MENTIONING the global variables at the top of an M-file allows the user to prevent any error RISING to usage of the same variable unconsciously. If we DECLARE it anywhere, it MAY so happen that we would need it at the beginning. Hence- it is plausible to declare it at the top of an M-file.

28.

A loop is used to avoid repetitive writing of the same function in the code.(a) True(b) FalseThis question was addressed to me in an online interview.My doubt stems from Fine Tuning topic in section Interacting with MATLAB of MATLAB

Answer»

The correct answer is (a) True

Explanation: The purpose of using loops is to AVOID WRITING the same line multiple times. The same line may be a particular function which computes a certain value. For the SAKE of accuracy, we may run the function multiple times, within a loop.

29.

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 filesThis question was addressed to me in examination.The origin of the question is M-Files in chapter Interacting with MATLAB of MATLAB

Answer» CORRECT option is (b) MAT files are BINARY DATA files while m-files are ASCII text files

Best explanation: M-files are ASCII text files which are used to simplify our program EDITING in MATLAB, they are basic text files. MAT files are Binary files created by MATLAB. When we need to save any data from the workspace, it is saved in MATLAB as a MAT file.
30.

What is the extension of script files?(a) .m(b) .mat(c) .script(d) There is a nothing called script fileThis question was addressed to me in an interview for job.My question is based upon M-Files in section Interacting with MATLAB of MATLAB

Answer»

Right OPTION is (a) .m

The BEST I can EXPLAIN: Script files are a kind of M-file. So to SAVE a script file, it has to saved with a .m extension. On the other hand, .mat extension is for MAT files.

31.

The function to plot a graph with both axes on logarithmic scales is __________(a) loglog(b) log(c) semilog(d) not possibleThe question was posed to me in homework.Enquiry is from Presenting Results topic in chapter Interacting with MATLAB of MATLAB

Answer»

Correct OPTION is (a) loglog

Explanation: There is no command CALLED semilog or log to plot a graph with logarithmic scales. However, we have the loglog function, pre-defined in MATLAB, which allows US to plot a graph of two VARIABLES where both the variables are scaled logarithmically.

32.

Which operator is used to prevent the printing of insignificant zeros?(a) %o(b) %nz(c) %g(d) It is not possibleI had been asked this question in exam.The question is from Presenting Results topic in portion Interacting with MATLAB of MATLAB

Answer»

Correct answer is (C) %G

The explanation: %g is USED to REPRESENT any number, which has a fixed number of digits or a number with an exponent, with no insignificant zeros. This is present in the MATLAB DIRECTORY only.

33.

What is the equivalent of subplot (1, 1, 1)?(a) subplot()(b) plot(c) It is not possible(d) axesI have been asked this question in an internship interview.The question is from Presenting Results topic in portion Interacting with MATLAB of MATLAB

Answer» RIGHT answer is (d) AXES

The explanation is: While using subplot (1,1,1), we have allocated MEMORY as a 2-D matrix for only 1 graph. This is similar to the axes COMMAND which generates an empty graph. This is pre-defined in MATLAB.
34.

The plotting of 3d plots and 2d plots requires separate windows. But the user has entered the hold on command. What is to be done?(a) Use the pause command(b) Use the hold off command(c) Use the close command(d) Nothing can be doneThis question was posed to me during an interview.I need to ask this question from Fine Tuning topic in portion Interacting with MATLAB of MATLAB

Answer»

The CORRECT option is (a) Use the PAUSE command

To elaborate: The hold off command is necessary to plot MULTIPLE graphs in the same window. Thus multiple 2d graphs or multiple 3d graphs can be drawn on the same window. But the pause command is used to KEEP the plot of 2d graphs and WAIT before generating 3d graphs. The close command closes any existing graphs.

35.

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 MATLABThis question was posed to me during an online interview.The above asked question is from Presenting Results topic in division Interacting with MATLAB of MATLAB

Answer»

Correct choice is (a) Using the HOLD function

To elaborate: The hold command is a pre-defined function in MATLAB. It ALLOWS the control to remain in the WINDOW where which was generated by MATLAB, the FIRST time we type a command to plot any KIND of graph. Then on we can plot multiple graphs on the same window.

36.

What is not displayed by the Workspace?(a) Time of variable generation(b) Standard deviation of the variable values(c) Class of the variables(d) Nature of the variablesThe question was posed to me in semester exam.The doubt is from The MATLAB Interface topic in chapter Interacting with MATLAB of MATLAB

Answer»

The correct answer is (a) Time of VARIABLE generation

To explain I would say: By right CLICKING on the Workspace header, we will get to KNOW the characteristics of the variables which are stored in the Workspace and what it can display. The time of variable generation is not present in the Workspace. It can only be seen if the variables from the workspace are saved separately USING the command ‘SAVE filename’.

37.

What is the default increment value in a for-loop?(a) 0(b) 1(c) An increment value is necessary(d) 0/1The question was posed to me in an internship interview.I need to ask this question from Loops in division Interacting with MATLAB of MATLAB

Answer» RIGHT answer is (b) 1

Easiest explanation: When we are GOING to start a for loop in MATLAB, it is not necessary to assign a specific increment value. The default increment value will then be TAKEN as 1.
38.

Where do we need to store a function to call it in other programs?(a) The bin folder(b) Anywhere(c) The MATLAB folder(d) DesktopI got this question by my college professor while I was bunking the class.My question is based upon The MATLAB Interface topic in division Interacting with MATLAB of MATLAB

Answer» RIGHT answer is (a) The BIN folder

To elaborate: M-files CONTAINING only a function has to be WRITTEN separately and has to be stored as .m files in the bin folder. If it stored in any other folder, MATLAB won’t be able to access the function file.
39.

How will one escape from printing graphs of variables, whose value gets changed for the program?(a) Use the clear all command at the beginning(b) Use the close all command at the beginning(c) Use the clc command(d) Cannot be escapedI had been asked this question in class test.I'm obligated to ask this question of Fine Tuning topic in division Interacting with MATLAB of MATLAB

Answer»

Right option is (a) Use the clear all command at the beginning

To EXPLAIN: The clear all command keeps all the local VARIABLES of the function unaffected i.e. they prevent their VALUES from getting changed due to some previous USAGE of the function. The close all command closes all the graphs the clc command removes the written code.