When you do simulation with matlab, writing scripts, which technique you used to choose when print out infos and when not print out infos?
comment lines at the beginning of code execution
조회 수: 4 (최근 30일)
이전 댓글 표시
I'm finding a way to comment every line where fprintf function appears if the value of DEBUG variable is setted to 0. for example:
if DEBUG == 0
comment all fprintf lines in my code
end
start the coding...
답변 (1개)
Image Analyst
2012년 10월 14일
편집: Image Analyst
2012년 10월 14일
I just set a flag and then put all fprintf's and msgbox's inside an if:
showDebugMessages = true; % or false.
....
if showDebugMessages
fprintf('About to run this section of code......\n');
end
...
if showDebugMessages
message = sprintf('The value is %f', value);
uiwait(msgbox(message));
end
댓글 수: 2
Image Analyst
2012년 10월 14일
Put the if outside the huge for loop. Of course this requires two for loops, one inside the if that has the fprintf, and in the "else" that does not check. But I can't see why you'd want to print something a million times anyway - talk about taking a long time. And how would you ever inspect all of them?
참고 항목
카테고리
Help Center 및 File Exchange에서 Environment and Settings에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!