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?
b) close all
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?
b) key word
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.
4. Command used to display the value of variable x.
c) disp 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?
size = [1 3]’ ; size(size)
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
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.
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;
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?
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?
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!