This is a common programming pattern that I see with new MATLAB users: They put more than one command per line in MATLAB file. This can make it harder to visually take in a file, and because profiler and error messages give information back based on the line number this practice will often hide the source command if they are nested or placed two on a line.
the reasoning for Matlab not being able to output the erroneous command is not quite reasonable to me since Matlab parses those lines in order to find the seperation in between the command (which is the semicolon).
So Matlab really *does* know which command is faulty!? So why not then output the suspicious command? Or can give me a more exhaustive reason why not?
I am not sure what the reason is for only giving the line number. It might be that the nomenclature “line 34, 3rd command” is just not very compelling.
What I do know is that code is easier to understand, and work with existing MATLAB reporting when it is one command per line.
Doug
Leave a Reply
About
Doug Hull is a proud MathWorker who is on a mission to help you with MATLAB.
Doug,
Does using one command per line incur an efficiency reduction?
~Jonathan
@Jonathan,
White space is purely visual. There is no downside to one command per line.
Doug
Doug,
the reasoning for Matlab not being able to output the erroneous command is not quite reasonable to me since Matlab parses those lines in order to find the seperation in between the command (which is the semicolon).
So Matlab really *does* know which command is faulty!? So why not then output the suspicious command? Or can give me a more exhaustive reason why not?
Tunc
Tunc,
I am not sure what the reason is for only giving the line number. It might be that the nomenclature “line 34, 3rd command” is just not very compelling.
What I do know is that code is easier to understand, and work with existing MATLAB reporting when it is one command per line.
Doug