필터 지우기
필터 지우기

fid value suppressing fprintf

조회 수: 2 (최근 30일)
Jeon
Jeon 2013년 11월 28일
댓글: Jeon 2013년 11월 28일
I'd like to make a program to display something when it is in a debug mode. Say,
fid = 0
fprintf(fid, 'do not display this')
fid = 1 % debug
fprintf(fid, 'print this')
I already know that 1 is for stdout, 2 is for stderr. However, it doesn't work when fid == 0.
And I am curious that which number suppresses fprintf?

채택된 답변

Walter Roberson
Walter Roberson 2013년 11월 28일
There is no fid the suppresses fprintf. Consider something like,
function dfprintf(DEBUG,varargin)
DEBUG && fprintf(varargin{:});
end
with a small bit of work you can make DEBUG a shared variable and use
dfprintf = @(varargin) DEBUG && fprintf(varargin{:});
  댓글 수: 1
Jeon
Jeon 2013년 11월 28일
Oh, that's sad. Thanks anyway.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by