MATLAB Questions and Answers – System Commands – 1

This set of MATLAB Multiple Choice Questions & Answers (MCQs) focuses on “System Commands – 1”.

1. The clipboard function cannot work without
a) Python
b) C
c) JAVA
d) Not present in MATLAB
View Answer

Answer: c
Explanation: The command has been designed in MATLAB such that it won’t work in a system where the JAVA Oracle software is not present. Hence, the only correct option is JAVA.

2. What is the output of the following code?

clipboard('copy',poe)

a) Logical Error
b) Copies ‘poe’
c) Copies poe
d) Syntactical Error
View Answer

Answer: d
Explanation: There is syntactical error in the following code. Since ‘poe’ is a string, it has to be declared within a pair of single inverted commas. Here it hasn’t been so which leads to an error and the correct answer is that there is a logical error.
advertisement
advertisement

3. What is the output of the following code?

Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!
clipboard(copy,’poe’)

a) Error
b) Copies poe
c) Copies poe to the MATLAB file
d) Copies poe to the MATLAB function
View Answer

Answer: a
Explanation: ‘copy’ is a parameter passed to the function clipboard. It is a string so it should be enclosed within ‘’. But here, copy has been passed to the function without any enclosement which will characterize it as a string. Hence, this leads to an error.
advertisement

4. What is the output of the following code?

clipboard[‘copy’,poe]

a) Error
b) Copies poe to a mlx file
c) Copies poe to a mat file
d) Copies poe to a mltbx file
View Answer

Answer: a
Explanation: The input to the clipboard command has to be within parentheses. Since the above input has been given within [], it leads to an error.
advertisement

5. What is the output of the following code?

clipboard(‘copy’,’poe’)
clipboard(‘paste’)

a) Prints poe
b) Prints ‘poe’
c) Prints error
d) Function not present in MATLAB
View Answer

Answer: b
Explanation: ‘poe’ is a stirng. Hence, it will be printed within ‘’. The correct option is that ‘poe’ will get printed.

6. What is the output of the following code?

system(cmd)

a) Starts Command Prompt
b) Starts Command Prompt in MATLAB
c) Starts Command Prompt in a separate window
d) Error
View Answer

Answer: d
Explanation: The input to the system command is a command which can be run through the OS. But the input int the above code isn’t given within ‘’. It should be within ‘’. Hence, this leads to an error.

7. What is the output of the above code?

system(‘cmd’)

a) Error
b) Starts Command Prompt in MATLAB
c) Starts Command Prompt in a separate window
d) Error
View Answer

Answer: b
Explanation: A separate window isn’t opened for the command prompt. It starts in MATLAB only. Thus the correct answer is that the Command Prompt starts in MATLAB.

8. What is the output of the following code?

system('cd')

a) Shows the current directory
b) Shows the directory where MATLAB is located
c) Error
d) The function doesn’t exist
View Answer

Answer: b
Explanation: cd is an OS command. The system command runs OS commands which are supported by the System. If we type ‘cd’ in Command Prompt, we get to know the current directory i.e. the path in the system where our control is currently present. Hence, here also, the current directory is shown.

9. What is the output of the following code?

system['cd']

a) Error
b) Syntactical error
c) Logical Error
d) Opens command prompt
View Answer

Answer: a
Explanation: The input to the above system command should be given within parentheses. Since it has been given within [], it leads to an error.

10. What is the output of the following code?

system('date')

a) Shows the date in your system
b) Shows the actual date
c) Shows the date when MATLAB was installed
d) Error
View Answer

Answer: a
Explanation: The above command shows the date which is displayed in the system. If it’s not the actual date, the command cannot differentiate and it’ll show what’s in your system. This is similar to the working in Command prompt and hence the correct answer is that it shows the date, currently saved, in the system.

Sanfoundry Global Education & Learning Series – MATLAB.

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

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). 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!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.