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 CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by