I'm new to Matlab and I have a function and I need to display a variable from running the main file (but the main file does access the function)...
I have tried to use fprintf(n);
Thanks :)
I'm new to Matlab and I have a function and I need to display a variable from running the main file (but the main file does access the function)...
I have tried to use fprintf(n);
Thanks :)
MATLAB関数はCの関数fprintf()と非常によく似ています。変数が整数の場合は、次のようにする必要があります。fprintf()n
fprintf('%d\n', n);
興味深い機能は、複数の数値とリテラルテキストを画面に印刷できることです。例えば
A1 = [9.9, 9900];
A2 = [8.8, 7.7 ; ...
8800, 7700];
fprintf('X is %4.2f meters or %8.3f mm\n', A1, A2);
ここ%4.2fで、の最初の列の要素をA1取り%8.3f、2番目の列を取ります。A2シーケンスでは、最初の行を印刷し、後で2番目の行を印刷するために繰り返します。出力は
Xは9.90メートルまたは9900.000mmです Xは8.80メートルまたは8800.000mmです Xは7.70メートルまたは7700.000mmです
で使用できる指定子の詳細が必要な場合はfprintf()、MathWorksのドキュメントを参照してください。