Dear all, I'm trying to implement a logging facility. For that reason, I want to replace my current calls fprintf(log_fid,"some label: %d\n, some_var) for something like myfprintf("some label: %d\n, some_var) and then call fprintf from within myprintf. My problem is that I don't know how to specificy the variable arguments list, I've tried like this:
function myfprintf(varargin)
fprintf(log_fid,varargin)
end
but that obviously won't work. Any suggestions? Thanks in advance. Best regards, Juan

1 件のコメント

Andrew Janke
Andrew Janke 2020 年 1 月 31 日
Hey, if you're doing logging in Matlab, consider trying my SLF4M framework instead of rolling your own: https://github.com/apjanke/SLF4M

サインインしてコメントする。

 採用された回答

Jan
Jan 2012 年 4 月 18 日

2 投票

function myfprintf(varargin)
fprintf(log_fid, varargin{:});
end

1 件のコメント

Juan Cardelino
Juan Cardelino 2012 年 4 月 18 日
Thank you, a couple of hours after asking the question I realized myself that I forgot the {:}
It works nice.

サインインしてコメントする。

その他の回答 (2 件)

supriya
supriya 2012 年 4 月 18 日

0 投票

Try this one...
disp(sprintf('%d %d',log_fid,varargin));
supriya
supriya 2012 年 4 月 18 日

0 投票

else
fprintf('%d %d',log_fid,varargin);

カテゴリ

ヘルプ センター および File ExchangeExponents and Logarithms についてさらに検索

質問済み:

2012 年 4 月 18 日

コメント済み:

2020 年 1 月 31 日

Community Treasure Hunt

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

Start Hunting!

Translated by