1.

A function is not returning values according to desired input values. What should be the correction?(a) Include clear all at the beginning of function file(b) Include close all at the beginning of function file(c) Include echo on in the function file(d) Cannot be solvedI had been asked this question during an online exam.I'd like to ask this question from M-Files in division Interacting with MATLAB of MATLAB

Answer»

Right answer is (a) Include clear all at the BEGINNING of function file

Best EXPLANATION: EVEN though the variables defined within a function are LOCAL variables, they might get affected due to the previous usage. So while execution of the same function, the user might get a different answer. Thus it is ADVISED to include clear all to remove all previous definitions of variables. The command ‘close all’ is used to clear the previously created graphs.



Discussion

No Comment Found

Related InterviewSolutions