sprintf does not work when called from a function

조회 수: 12 (최근 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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Entering Commands에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by