What is the output of the following code? [code][q,r]=eval(‘sprintf('23 45')’)[/code]

Hương Trang

New member
What is the output of the following code?
Code:
[q,r]=eval(‘sprintf('23 45')’)
A. Unexpected MATLAB expression
B. q=23,r=45
C.
q = 23
r = 45
D. Error due to eval
 
Answer: a
Explanation: The eval command returns an error if more than a pair of inverted commas are found. Hence, unexpected MATLAB expression is correct option. Option q=23,r=45 cannot happen since 23 and 45 will be stored in a single character array.
 

Tìm kiếm

Back
Top