How do I use either "printf()" or "mexPrintf()" when either call gets me "Unknown function or variable"?

12 ビュー (過去 30 日間)
I am new to Matlab on a Mac, having used Matlab and Octave in Linux environments for years. I find
that I cannot use "printf" or what I see described as "mexPrintf" to show variables in the command line window.
I get the error message "Unknkown function or variable". Is there some path addition that I need to do in order
that this Matlab see all the available functions? Or are these functions considered beyond the reasonable need
of a "home" user of Matlab?
  2 件のコメント
James Tursa
James Tursa 2018 年 11 月 19 日
Those are C/C++ functions. Are you writing mex code or m-code?
Steve Mims
Steve Mims 2018 年 11 月 20 日
m-code. A google search led me to trying mexPrintf().

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

採用された回答

James Tursa
James Tursa 2018 年 11 月 19 日
Typically use disp( ) or display( ) or fprintf( ) to display variables in the command window.
  2 件のコメント
Steve Mims
Steve Mims 2018 年 11 月 20 日
That's the ticket. fprintf() In Octave it is printf for printing out formatted variables to the command line. I think it is also like that in Linux-based Matlab. Anyway, fprintf() seems to work. I'm used to using that function for printing to a file, not the command line.
James Tursa
James Tursa 2018 年 11 月 20 日
If you supply a file I/O parameter as the 1st argument, fprintf also writes to files.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Import and Analysis についてさらに検索

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by