Errors in Input

MATLAB

This set of MATLAB Multiple Choice Questions & Answers (MCQs) focuses on “Errors in Input – 1”.

1. What will be the output of the following code?

A=sim(pi)+cod(pi)

a) A=-1
b) Undefined function or variable ‘cod’
c) Undefined function or variable ‘sim’
d) Undefined function or variable ‘sim’ and ‘cod’

2. What is the output of the following code?

A=[1 2 3]; A^2;

a) [1 4 9]
b) A= 1 4 9
c) A= [1, 4, 9]
d) Inputs must be a scalar or a square matrix

3. What is the output of the following code?

A=[1 1; 1 1]; A^2

a)

A = 2 2
    2 2

b)

A = 1 1
    1 1

c) Error using ^ To compute element wise POWER, use POWER (.^) instead
d) No output

4. What is the output of the following code?

A=[1 2]; B=[1 4]; c=A*B;

a) c= [1 8]
b)

c = 1
    8

c) Inner Matrix dimensions must agree
d) No output since we have closed the line of code with a semicolon

5. What is the output of the following line of code?

			t=0:pi/8:4pi;

a) No output as we’ve closed the line of code with a semi-colon
b)

1      2        3        4        5        6        7       8        9
0    1.5708   3.1416   4.7124   6.2832   7.8540   9.4248  10.9956  12.5664

c) Error: Unexpected MATLAB expression
d) Undefined function or variable ‘pi’

6. What is the error in the code?

a=[[1;2];(2,3)]

a) Third brackets are wrong
b) The semicolon within the second third brackets
c) There is no error
d) Error: Expression or statement is incorrect–possibly unbalanced

7. What is the output in the following code?

a=[[1;22],[53;9],[13;2]];

a) There is no output
b) Columns are to be introduced by placing semi-columns
c) Dimensions of matrices being concatenated are not consistent
d)

a = 1    53    13
   22     9     2

8. What is the difference between the two codes?

a> P=[91,’pi’];
b> Q=[91,pi];

9. What is the output of the following code?

P=tan90

a) Inf
b) P = Inf
c) P = -1.9952
d) Undefined function or variable ‘tan90’

10. What is the output for the following code?

if(a>b) p=9;

a) No output
b) Never will there be an output
c) a, b, p are not initialized
d) p=9

11. What is the output of the following code?

P=sin[90];

a) P = 1
b) P = .8932
c) P = .99999
d) Error

12. What is the output of the following code?

system(cmd)

a) Opens command prompt
b) Opens command prompt in a separate window
c) Opens command prompt in MATLAB
d) Error

13. Why is the output, as shown, ‘poe’?

>>clipboard(‘paste’, ‘Do re Mi fa’)
ans =
      ‘poe’

a) ‘poe’ was initially in the clipboard
b) Cannot be determined
c) Error
d) The text gets changed

14. What is the output of the following code?

clipboard('cut','Do re Mi fa')

a) Error due to syntax
b) Error due to command
c) Error due to cut
d) Cuts the portion of a text where ‘Do re Mi fa’ is written.

15. What is the output of the following code?

isvector((49 32));

a) Error in ()
b) Error due to absence of comma
c) Error due to command
d) Logical 1

16. What is the output of the following code?

clipboard('Do re Mi fa','copy')

a) Error in hierarchy
b) Copies the input text to the system clipboard
c) Replaces any text, in the clipboard, with the input text
d) Syntactical Error

17. What is the output of the following code?

commandhistory[]

a) Error
b) Shows command history
c) Shows the previous command used
d) Prints all the commands used for the current session

18. What is the output of the following code?

pd=makedist('Uniform','Lower',3)

a) Error in giving limits
b) A uniform distribution with lower limit 3 and upper limit Infinity
c) Error in syntax
d) Error due to the command

19. What is the output of the following code?

p=input('');
po

a) ‘po’ gets assigned to p
b) Error in the input
c) Error due to syntax
d) Cannot be determined

20. What is the output of the following code?

p=input[''];

a) Asks for an input
b) Error in the input
c) Error due to syntax
d) Cannot be determined

21. What is the output of the following code?

pd=makedist('Uniform','-Inf',lower,'Inf',upper)

a) Makes a uniform distribution ranging from -Inf to Inf
b) Error due to Inf
c) Error due to syntax
d) Logical Error

22. What is the output of the following code?

sumsqr([1 2; 'NaN' 4])

a) 21
b) Error due to NaN
c) Error due to ‘NaN’
d) 9

23. The uniform distribution can range from -infinity to 0 or 0 to Infinity but not from -infinity to infinity.
a) True
b) False

24. If a character input is given to a command which only takes integers, it’ll always give an error.
a) True
b) False

Leave a Reply

Your email address will not be published. Required fields are marked *