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

assembly - What is the addressing mode for ld, add, and rjmp instructions? -

vowpalwabbit - Interpreting Vowpal Wabbit results: Why are some lines appended by "h"? -

ubuntu - Bash Script to Check That Files Are Being Created -