MATLAB
MATLAB
Explanation: MATLAB stands for matrix laboratory which is multi-paradigm numerical computing
environment and fourth-generation programming language.
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.
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.
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)
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.
Explanation: It forms a 2×1 matrix of 3 and 1 because transpose condition is there, so size (a) returns
transposed value.
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.
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.
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
Explanation: 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.
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.
13. The help command works only for a pre-defined function in MATLAB.
a) True b) False
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.
Explanation: 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.
Explanation: 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.
16. The command used to reflect the files from a disk into the workspace is _______
a) load b) show c) disp() d) it is not possible
Explanation: The load function is pre-defined in MATLAB. It is used to load variables and/or data from the
disk to the workspace.
17. The format for 5 digit representation along with exponent is __________
a) short e c) short exp
b) short g d) 4 digit along with exponent value can be represented
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
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.
19. The function to plot a graph with both axes on logarithmic scales is __________
a) loglog b) log c) semilog d) not possible
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.
20. We cannot plot a discrete and continuous relationship in the same graph.
a) True b) False
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.