hi , i use the following statement ,

1 回表示 (過去 30 日間)
mohammed hamdy
mohammed hamdy 2016 年 9 月 28 日
コメント済み: Walter Roberson 2016 年 9 月 28 日
fprintf('S=%d Z0 =%d PHI=%d MSEreal=%d MSEfuzzy=%d Numberofreal=%d Numberoffuzzy=%d\n', s,z0,phi,MSEreal,MSEfuzzy,numberreal,numberfuzzy);
for s=7 and z0=0.2 and phi=0.6 and so ,
the result show this values in terms of e . as following
S=7 Z0 =2.000000e-01 PHI=6.000000e-01 MSEreal=1.732151e-04 MSEfuzzy=1.070943e-04 Numberofreal=127 Numberoffuzzy=223
how to display result without e ?.

採用された回答

Massimo Zanetti
Massimo Zanetti 2016 年 9 月 28 日
If you want to show decimal numbers just do this:
fprintf('S=%d Z0=%.1f PHI=%.1f MSEreal=%.1f MSEfuzzy=%.1f Numberofreal=%d Numberoffuzzy=%d\n', s,z0,phi,MSEreal,MSEfuzzy,numberreal,numberfuzzy);
  2 件のコメント
mohammed hamdy
mohammed hamdy 2016 年 9 月 28 日
thank u very much
Walter Roberson
Walter Roberson 2016 年 9 月 28 日
Right. The %d format is only for values that are integral. Logical values convert to integral and so can be printed using %d; characters convert to integral and so can have their numeric position printed using %d.
Complex values printed with %d will have their complex part discarded.
Any numeric value that (after discarding of any complex component) is not integral will be printed by %d format using scientific format.
If you have a value that is not integral and you wish to print it without scientific notation then your options are:
  • floor() or fix() or round() it so that it becomes integral, and continue to use %d format
  • use %.f or %.0f format to print it without any decimal place, even if it is a large number; the number will be rounded to the nearest integer
  • use %.Nf where N is a positive integer, to print with N decimal places after the period; the last decimal place printed will represent rounding
The %g format can also be useful for printing floating point numbers, but it will switch between integer (%d) and fixed point (%f) and exponential format depending on how well the number fits into the width (default: 5) specified.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Type Conversion についてさらに検索

タグ

タグが未入力です。

Community Treasure Hunt

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

Start Hunting!

Translated by