matlab - rounding to n significant digits -



matlab - rounding to n significant digits -

i'm trying write code in matlab round number (as ask) important digits.

i'm not sure how it. suggestions?

to round d significant digits:

>> d = 3; %// number of digits >> x = 5.237234; %// illustration number >> d = 10^(d-ceil(log10(x))); >> y = round(x*d)/d y = 5.2400

to round d decimal digits:

>> d = 3; %// number of digits >> x = 5.237234; %// illustration number >> d = 10^d; >> y = round(x*d)/d y = 5.2370

matlab floating-point digits significant-digits

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -