Round with significant digits

버전 1.6.0.0 (3.05 KB) 작성자: François Beauducel
Rounds towards the nearest number with N significant digits.
다운로드 수: 6.7K
업데이트 날짜: 2015/4/3

라이선스 보기

편집자 메모: This file was selected as MATLAB Central Pick of the Week

This little function rounds a number (or the elements of a vector ot matrix) towards the nearest number with N significant digits.
Examples:
roundsd(0.012345,3) returns 0.0123
roundsd(12345,2) returns 12000
roundsd(12.345,4,'ceil') returns 12.35
This is a useful complement to Matlab's ROUND, ROUND10 and ROUNDN (Mapping toolbox), especially when dealing with data with a large variety of order of magnitudes.

I was about to upload this file when I found "sd_round.m" by Edward Zechmann (see aknowledgment), which has similar feature (and more). But, because my script is very different in coding (much much shorter), I decided to share it anyway.

인용 양식

François Beauducel (2024). Round with significant digits (https://www.mathworks.com/matlabcentral/fileexchange/26212-round-with-significant-digits), MATLAB Central File Exchange. 검색됨 .

MATLAB 릴리스 호환 정보
개발 환경: R13
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux
카테고리
Help CenterMATLAB Answers에서 Coordinate Reference Systems에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!
버전 게시됨 릴리스 정보
1.6.0.0

fix a problem with vectors with negative and positive exponent values (problem since the last update only).

1.5.0.0

solve the floating point arithmetic problem with roundsd(3.55,2) pointed out by Will and Yuri K.

1.3.0.0

- adds different methods for rounding;
- corrects a bug for 0 values (now produces 0 instead of NaN), thanks to Daniel Armyr's comment.

1.2.0.0

works with negative numbers.

1.1.0.0

works with negative numbers.

1.0.0.0