hi , i use the following statement ,

13 vues (au cours des 30 derniers jours)
mohammed hamdy
mohammed hamdy le 28 Sep 2016
Commenté : Walter Roberson le 28 Sep 2016
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 ?.

Réponse acceptée

Massimo Zanetti
Massimo Zanetti le 28 Sep 2016
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 commentaires
mohammed hamdy
mohammed hamdy le 28 Sep 2016
thank u very much
Walter Roberson
Walter Roberson le 28 Sep 2016
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.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Tags

Aucun tag saisi pour le moment.

Community Treasure Hunt

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

Start Hunting!

Translated by