Professional Documents
Culture Documents
3. What are the files used for executing a list of commands repeatedly in
MATLAB called?
a) Script files
b) Function files
c) Text files
d) Command files
Answer: a) Script files
Answer: c) .m
9. How can the state variables in the workspace affect the execution of a
script file?
a) They can speed up the execution of the script file.
b) They can slow down the execution of the script file.
c) They can cause unexpected behavior in the execution of the script file.
d) They have no effect on the execution of the script file.
13. What is the advantage of using M-File functions over script files in
MATLAB?
a) M-File functions are easier to write and debug.
b) M-File functions do not have any side-effects on the base workspace.
c) M-File functions can be executed more quickly than script files.
d) M-File functions can be used to overwrite variables in the base
workspace.
Answer: b) To define the function name and the inputs and outputs.
17. Which part of an M-File function contains the program code that
performs the actual computations?
a) Function definition line
b) H1 line
c) Help text
d) Function body
18. Can scripts have all the elements shown in Table 4.1?
a) Yes, scripts can have all the elements except for the function
definition line.
b) No, scripts do not have any of the elements shown in Table 4.1.
c) Yes, scripts can have all the elements including the function definition
line.
d) Scripts can only have the function body element.
Answer: a) Yes, scripts can have all the elements except for the function
definition line.
Answer: c) 63 characters
Answer: d) .m
27. What are the three ways to assign values to variables in a script file
in MATLAB?
a) The variable is defined in the script file, it is defined in the command
prompt, or it is entered when the script is executed.
b) The variable is assigned a value automatically, it is assigned a value
by the user, or it is assigned a value by the system.
c) The variable is defined in the script file, it is defined in the function
file, or it is defined in the command window.
d) The variable is assigned a value by the user, it is assigned a value by
the system, or it is assigned a value randomly.
31. What are the two commands frequently used to generate output in
MATLAB?
a) input and output
b) disp and fprintf
c) define and output
d) display and print
32. What is the main difference between the disp and fprintf commands
in MATLAB?
a) disp provides total control over the appearance of output, while fprintf
provides limited control over the appearance of output.
b) fprintf is simpler to use than disp.
c) disp provides limited control over the appearance of output, while
fprintf provides total control over the appearance of output.
d) fprintf is used to generate automatic displays, while disp is used to
generate user-defined displays.
35. What are the decision making structures for control of command
execution in MATLAB?
a) Functions and scripts
b) Variables and assignments
c) Control flow structures
d) Input and output commands
36. What are the three control flow structures that MATLAB include ?
a) if-else-end, for loop, and while loop
b) if-then-else, do-while, and switch-case
c) if-then-else, for loop, and switch-case
d) if-else-end, do-while, and switch-case
38. Does MATLAB need to compile programs before they can be run?
a) Yes, MATLAB needs to compile programs before they can be run.
b) No, MATLAB is an interpretative language and does not require
programs to be compiled.
c) Only script files need to be compiled, function files do not.
d) It depends on the size of the program.
39. Can users add their own functions to MATLAB using M-files?
a) Yes, users can add their own functions to MATLAB using M-files.
b) No, MATLAB does not allow users to add their own functions.
c) Users can only add functions to MATLAB using compiled code.
d) Users can only add functions to MATLAB using script files.
Answer: a) Yes, users can add their own functions to MATLAB using
M-files.
44. What are the steps required to save output to a file in MATLAB?
a) Open a file using fopen, write the output using fprintf, close the file
using fclose
b) Open a file using fprintf, write the output using fopen, close the file
using fclose
c) Open a file using fclose, write the output using fprintf, close the file
using fopen
d) Open a file using fwrite, write the output using fprintf, close the file
using fclose
Answer: a) Open a file using fopen, write the output using fprintf, close
the file using fclose