What is the output of the following code? [code]MException('MATLAB:test', '%d * %d= Why?', Inf,Inf)[/code]

Ngô Quốc Huy

New member
What is the output of the following code?
Code:
MException('MATLAB:test', '%d * %d= Why?', Inf,Inf)
A.
Code:
    MException with properties:
    identifier: ‘MATLAB:test’
    message: 'Inf * Inf= Why?'
    cause: {}
    stack: [0×1 struct]
B.
Code:
    MException with properties:
    identifier: “MATLAB:test”
    message: 'Inf * Inf= Why?'
    cause: []
    stack: [0×1 struct]
C.
Code:
    MException with properties:
    identifier: ''MATLAB:test’
    message: '%d * %d= Why?'
    cause: {}
    stack: [0×1 struct]
D. Error
 
Answer: a
Explanation: %d would get converted to the value given as an argument after the message input in the MException command. The cause is not specified so it would remain a cell array, identified by {}. The identifier is shown within a ‘’ and not “”.There is no error in the code.
Output:
Code:
    MException with properties:
    identifier: ‘MATLAB:test’
    message: 'Inf * Inf= Why?'
    cause: {}
    stack: [0×1 struct]
 

Tìm kiếm

Back
Top