Syntax Error

MATLAB

This set of MATLAB Multiple Choice Questions & Answers (MCQs) focuses on “Syntax Error”.

1. What is the error in the following?

input(“pop”)

a) None
b) “”
c) Parentheses
d) No such command

2. What is the error in the following code?

for i={1: 10}
p=a+1
end

a) None
b) {}
c) The : operator
d) Cannot be determined

3. What is the output of the following code?

limit[1/x,0]

a) NaN
b) Inf
c) Syntactical Error
d) Logical error

4. What is the output of the following code?

length{ 1 2 }

a) Error due to space after 2
b) Error due to {}
c) Syntactical Error
d) 2

5. What is the output of the following code?

limit((1 + 1/n)^n,n=Inf)

a) e
b) exp(1)
c) Syntactical Error
d) Cannot be determined

6. What is the output of the following code?

A={1 2 3 4}
sum(A)

a) Error
b) 10
c) { 10 }
d) Logical Error

7. What is the output of the following code?

limit({sin(x)/x},x,Inf,right)

a) 0
b) Inf
c) Syntactical error
d) Error due to inconsistency in approaching limit

8. What is the output of the following code?

mean({1 2 3})

a) 2
b) Logical Error
c) 1
d) Syntactical Error

9. What is the output of the following code?

det({1 2 3; 4 5 6; 7 8 9})

a) 0
b) Syntactical Error
c) A very small value
d) Cannot be determined

10. What is the output of the following code?

(1 2);

a) A cellular vector of dimension 1*2
b) A vector of dimension 1*2
c) A matrix of dimension 1*2
d) Error

11. What is the output of the following code?

p=[1 3 2]; roots[p];

a) Syntactical Error
b) Undefined roots
c) -2,-1
d) Cannot be determined

12. What is the output of the following code?

poly[ 1 2 3]

a) x + 2x + 3x2
b) x3 + 2x2 + x
c) Error
d) Cannot be determined

13. What is the output of the following code?

polyint[{1 2 3}]

a) Syntactical error due to []
b) Syntactical Error due to {}
c) Logical Error
d) [1/2,1,3]

14. What is the output of the following command?

>> x={1 2 3};
>> t=[1 2 3];
>> plot(x,t)

a) plots a ramp function
b) plots r(t)-r(t-3)
c) Error due to plot
d) Error due to x

15. The input to the polar command is not necessary to be within parentheses.
a) True
b) False

16. What is the output of the following code?

for ( i=1:10 )
if{i<3}
break
end
end

a) Syntactical Error
b) Logical Error
c) i=1
d) i=2

17. What is the final value of i?

for i=[1:10]
end

a) 0
b) 1
c) Error
d) 10

18. What is the output of the following code?

syms p q;
x=p+2q;
findsym[x]

a) Syntactical Error
b) p,q
c) No such command
d) p

19. What is the output of the following code?

syms p q;
x=p+2*q;
diff[x];

a) 1
b) 0
c) Syntactical Error
d) Logical Error

20. What is the output of the following code?

syms pi;
p=2sin[pi]/cos[pi] + tan[3pi];

a) 0
b) A value very close to 0
c) Syntactical Error
d) Error in the expression

21. What is the output of the following code?

solve[‘x^2+1=0’]

a) x=j,-j
b) x=+i,-i
c) Syntactical Error
d) Logical Error

22. What is the output of the following code?

syms [p,q]

a) Establishes p and q as symbolic variables
b) Syntactical Error
c) Logical Error
d) Only p is symbolically defined

23. Vectors defined by [] can be cellular vectors.
a) True
b) False

24. What is the output of the following code?

tf2zp({1 2}, {2 1})

a) 0
b) Returns the zeros and poles of the transfer function (s+2)/(2s+1)
c) Syntactical Error
d) Logical Error

25. What is the output of the following code?

error{“404”}

a) 404
b) Error in the command
c) Error 404
d) Syntactical Error

26. What is the output of the following code?

warning(“a”)

a) Warning: a
b) Error in the code
c) Syntactical Error
d) Logical Error

27. What is the output of the following code?

syms ‘t’,’p’;

a) Both t and p are defined as symbolic
b) Only t gets defined as symbolic
c) Only p gets defined as symbolic
d) Nothing happens

28. What is the output of the following code?

poly{1,2}

a) Syntactical Error
b) 1 3 2
c) Cannot be determined
d) 0

Leave a Reply

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