MATLAB Questions and Answers – The MATLAB Interface

This set of MATLAB Multiple Choice Questions & Answers (MCQs) focuses on “The MATLAB Interface”.

1. Which functions help you to save and load variables?
a)

>> save Lays [a,b]
>> load('myfile.mat')

b)

>> save Lays {a b}
>> load myfile.mat

c)

>> save Lays “a,b”
>> load(myfile.mat)
advertisement
advertisement

d)

>> save Lays a b
>> load('myfile.mat')
View Answer
Answer: d
Explanation: There is a pre-defined function in MATLAB to store the variable values from your workspace permanently called ‘save filename’. Option d is the correct command syntax for calling it.

Output: 
>>a=5;b=a;
>> save Lays a b;     % Now go to workspace and delete the variables
>> load('Lays.mat');%Check workspace.
 
 

2. To add comments in MATLAB, use _________
a) //
b) %/
c) /%
d) %
View Answer

Answer: d
Explanation: The only format for adding and storing comments in MATLAB is to use the % symbol. One can choose to end a comment using %, but it is not needed.
Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!

3. To display comments of M-file, we use ____________
a) echo on
b) comment on
c) show %
d) Cannot be displayed
View Answer

Answer: a
Explanation: The echo command is used to display commands present in an M-file. If the M-file has any comments, the echo command will also display the comments.

4. 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) Desktop
View Answer

Answer: a
Explanation: 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.
advertisement

5. 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 toolbox
View Answer

Answer: c
Explanation: 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.

6. What will the following set of commands do when they are present in a script file?

advertisement
stem[y1,y2];
title(‘p’);
print -deps p

a) Plot the discrete graph of y1 and y2
b) There is no stem command in MATLAB
c) Store the graph as a separate file
d) Cannot be determined
View Answer

Answer: c
Explanation: The given format of the print statement is used to store the graphs of y1 and y2 generated due to previous definitions of y1 and y2. If we only use the print command, the graph y1 and y2 will get displayed.

7. The function to close the windows containing graphs generated from MATLAB is __________
a) close all
b) close graphs
c) delete graphs
d) end all
View Answer

Answer: a
Explanation: 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.

8. 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 variables
View Answer

Answer: a
Explanation: 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’.

9. MATLAB allows modelling of different control systems using ___________
a) Simulink
b) Control System Toolbox
c) Not available in MATLAB as of yet
d) ezplot
View Answer

Answer: a
Explanation: 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.

10. 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) Quit
View Answer

Answer: a
Explanation: 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.

11. 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 files
View Answer

Answer: c
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.

Sanfoundry Global Education & Learning Series – MATLAB.

To practice all areas of MATLAB, here is complete set of 1000+ Multiple Choice Questions and Answers.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.