Recently Matlab has been having an odd glitch: when I call scripts, sections of text from those scripts appear in the command window, often repeated again and again (as when the script is going through a loop). This is harmless in that it doesn't affect the processing of the scripts, but frustrating when I want to have some output visible in the command window and it is filled with thousands of lines of code!
For instance, if I run a sample file, the command window looks like this:
>> samplefile
%This is a sample file
%It doesn't really do anything
a=[6 2 3];
b=[3 4 4];
result=a+b;
disp(result);disp(clock);
9 6 7
2020 1 10 14 47 9.4269
I've checked that diary is off, but other than that am not sure what to check or reset to stop this from happening.

 채택된 답변

Walter Roberson
Walter Roberson 2020년 1월 10일

1 개 추천

댓글 수: 4

Colin Raymond
Colin Raymond 2020년 1월 10일
편집: Colin Raymond 2020년 1월 13일
This seemed to work briefly, but in the same Matlab session the issue reappeared and so I'm set back to square one. 'Echo' and 'diary' are both off, yet script text keeps showing up in the command window.
Steven Lord
Steven Lord 2020년 1월 13일
That suggests some code that you're executing turns echo on again at some point. You could try to use dbstop to stop just before echo executes and edit the code to remove the extraneous echo call (or if the echo is necessary make sure it gets turned off, perhaps by using an onCleanup object to ensure it's turned back off even if the function throws an error.)
Yes, I know echo is a built-in function. From the dbstop documentation: "If file is not a MATLAB code file (for instance, it is a built-in or MDL-file), then MATLAB issues a warning. MATLAB cannot pause in the file, so it pauses before executing the file."
Stephen23
Stephen23 2020년 1월 14일
A simple way to find where the extraneous echo call is to temporarily shadow it with a function that throws an error.
Using dbstop (very useful) and a test script to check whether echo is on or off led me to find that the issue can be traced to the ncgeodataset object (in the nctoolbox library). Interestingly, none of these scripts leave echo on, so far as I can tell, and also calling ncgeodataset itself isn't the problem, but rather it happens when a variable is called from a file that was created using ncgeodataset. So
file=ncgeodataset('weatherdata.grib');
results in echo staying off, but
thisvar=file{'2_metre_temperature'};
results in echo on. Following each such statement with
echo off
therefore solves the problem (though not quite explaining it!). Thanks all for the assistance.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Desktop에 대해 자세히 알아보기

질문:

2020년 1월 10일

댓글:

2020년 1월 14일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by