sprintf does not work when called from a function

9 ビュー (過去 30 日間)
Zoltán Csáti
Zoltán Csáti 2014 年 10 月 4 日
コメント済み: Zoltán Csáti 2014 年 10 月 4 日
I would like to use the advantages of sprintf over disp, but I have a problem with it. From my main function I invoke an other function which contains the command sprintf. As a result, nothing is printed out to the screen. That specific function is called many times, therefore I do not want to dismiss that function and use the main function only. What can I do? I need the formatting capabilities of sprintf that disp can not provide.
Thanks, Zoli

採用された回答

dpb
dpb 2014 年 10 月 4 日
sprintf doesn't print to command window, it writes output to a string variable so unless you left the trailing ";" off the line in the m-file of the function that's expected behavior.(*)
Use fprintf instead...
doc fprintf % for details
  1 件のコメント
Zoltán Csáti
Zoltán Csáti 2014 年 10 月 4 日
Thank you. This is what I was looking for.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeEntering Commands についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by