# 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

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

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

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

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.
Note: Join free Sanfoundry classes at Telegram or Youtube

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

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?

Take MATLAB Mock Tests - Chapterwise!
Start the Test Now: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
`size = [1 3]’        ;  size(size)`

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

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.

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

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

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

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

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

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

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. 