MATLAB Answers

How to find from what row an outprint comes from

57 views (last 30 days)
Fredrik
Fredrik on 11 Nov 2011
Hi Everyone. For some reason i get a very large "data print" in the command window when i import data with my import file. For what I can see, I have put ; in the end of every row which I thought would terminate all kinds of outputs.
Now I wonder if there is any command that can look from which row in my m file this data print comes from? Thank you! Fredrik Lindelöw

  0 Comments

Sign in to comment.

Accepted Answer

Fangjun Jiang
Fangjun Jiang on 11 Nov 2011
The "data print" might be generated by fprintf() though.
Anyway, you can turn on echo and then run the code. It will interlace your code and the output. Then you can find it out.
echo on;

  2 Comments

Jan
Jan on 11 Nov 2011
+1: After all these years I learn a situation when ECHO is useful. Thanks.
Fangjun Jiang
Fangjun Jiang on 11 Nov 2011
For this question, I though about echo() right away. But in this similar previous question, it took me a while to thought about it.
http://www.mathworks.com/matlabcentral/answers/17651-why-do-i-get-ans-1-in-the-command-window

Sign in to comment.

More Answers (3)

Jan
Jan on 11 Nov 2011
You can use the debugger also: Set a breakpoint in the code and step through the program line by line until the output appears.
There might be a disp or display, an unterminated line in a subfunction, or a comma after a command e.g. when twi commands are written to a single line.

  0 Comments

Sign in to comment.


Walter Roberson
Walter Roberson on 11 Nov 2011
dbstop in disp
dbstop in fprintf
and possibly even
dbstop in display

  0 Comments

Sign in to comment.


Fredrik
Fredrik on 11 Nov 2011
Thank you very much, never thought this woulf be such an interesting quiestion! I will try your advice as soon as possible!

  0 Comments

Sign in to comment.

Sign in to answer this question.