MATLAB Questions and Answers – Input and Output

»

This set of MATLAB Multiple Choice Questions & Answers (MCQs) focuses on “Input and Output”.

1. MATLAB stands for?
a) matrix laboratory
b) math library
c) matric library
d) matrix library
View Answer

Answer: a
Explanation: MATLAB stands for matrix laboratory which is multi-paradigm numerical computing environment and fourth-generation programming language.
advertisement

2. Which command is used to clear a command window?
a) clear
b) close all
c) clc
d) clear all
View Answer

Answer: c
Explanation: clc clears all input and output from the Command Window display and provide a “clean screen”. After using clc, you cannot use the scroll bar to see the history of functions, but you still can use the up arrow key, ↑, to recall statements from the command history.

3. To determine whether an input is MATLAB keyword, command is?
a) iskeyword
b) key word
c) inputword
d) isvarname
View Answer

Answer: a
Explanation: Command iskeyword uses the MATLAB command format. iskeyword returns a list of all MATLAB keywords. It gives output in the form of 1 and 0.
advertisement
advertisement

4. Command used to display the value of variable x.
a) displayx
b) disp(x)
c) disp x
d) vardisp(‘x’)
View Answer

Answer: b
Explanation: disp(X) displays the value of variable X without printing the variable name. Another way to display a variable is to type its name, but this displays a leading “X =”, which is not always ideal. If a variable contains an empty array, disp returns without displaying anything.

5. Which of the following statements shows the result of executing the following line in the editor window?

advertisement
size = [1 3]’        ;

size(size)

a) error
b) 1 3
c) 3 1
d) 3 3
View Answer

Answer: a
Explanation: Executing the command iskeyword size returns 0, i.e., size is not a MATLAB keyword. Same command should not be used as a variable in MATLAB, so there is a error message.
advertisement

6. Executing in the command window the following code returns.

 a = [1:3]’ ;
size(a)

a) error message
b) 1 3
c) 3 1
d) 31
View Answer

Answer: c
Explanation: It forms a 2×1 matrix of 3 and 1 because transpose condition is there, so size(a) returns transposed value.
advertisement

7. Command is used to save command window text to file.
a) saveas
b) texttofile
c) diary
d) todiary
View Answer

Answer: c
Explanation: The diary function creates a log of keyboard input and the resulting text output, with some exceptions. The output of diary is an ASCII file, suitable for searching in, printing, inclusion in most reports and other documents.

8. Executing in the editor window the following code returns.

a = 1;	sin(a)	a = 2;

a) 0.4815
b) 0.8415
c) 1
d) 0.9093
View Answer

Answer: b
Explanation: It chooses the value of a is 1 because it follows line pattern as it neglects 2 because this command is written after sin command.

9. To stop the execution of a MATLAB command, used keys?
a) ctrl+c
b) ctrl+s
c) ctrl+b
d) ctrl+enter
View Answer

Answer: a
Explanation: Ctrl+C stop execution for files that run a long time, or that call built-ins or MEX-files that run a long time. Ctrl+Break is also used to stop the execution.

10. Which is the invalid variable name in MATLAB?
a) x6
b) last
c) 6x
d) z
View Answer

Answer: c
Explanation: A valid variable name starts with a letter, followed by letters, digits, or underscores. MATLAB is case sensitive, so A and a are not the same variables, and in 6x digit is followed by a letter which is invalid.

Sanfoundry Global Education & Learning Series – MATLAB.

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

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!

advertisement
advertisement
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He is Linux Kernel Developer & SAN Architect and is passionate about competency developments in these areas. He lives in Bangalore and delivers focused training sessions to IT professionals in Linux Kernel, Linux Debugging, Linux Device Drivers, Linux Networking, Linux Storage, Advanced C Programming, SAN Storage Technologies, SCSI Internals & Storage Protocols such as iSCSI & Fiber Channel. Stay connected with him @ LinkedIn | Youtube | Instagram | Facebook | Twitter