hi , i use the following statement ,
1 次查看(过去 30 天)
显示 更早的评论
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
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 个评论
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 Exchange 中查找有关 Data Type Conversion 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!