필터 지우기
필터 지우기

Turning all elements of a column array into the same factor of 10

조회 수: 1 (최근 30일)
Saeid
Saeid 2023년 8월 20일
댓글: John D'Errico 2023년 8월 20일
I have an array that looks like this:
X=[19.9 20 20 20.1 20.12 19.81 20 20 20 ... ]
So it is predomintantly an integer factor of 10 (but naturally I don't know in advance what is). What is the easiest way to turn all of the numbers into 20 (or any factor of 10)?

채택된 답변

Image Analyst
Image Analyst 2023년 8월 20일
편집: Image Analyst 2023년 8월 20일
Try round
X = [19.9, 20, 20, 20.1, 20.12, 19.81, 20, 32, 46];
rounded = round(X, -1)
rounded = 1×9
20 20 20 20 20 20 20 30 50

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

제품


릴리스

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by