How to round numbers to specific near point?

조회 수: 1(최근 30일)
Triveni
Triveni 2022년 6월 22일
답변: Stephen23 2022년 6월 22일
I have a vector
A =
6.1
6.04
5.98
5.92
5.86
5.8
5.74
5.69
5.63
5.57
5.52
5.46
5.41
i want to round it near 0.05,
A =
6.1
6.05
6
5.9
5.85
.
.
.
Please help me.

채택된 답변

Stephen23
Stephen23 2022년 6월 22일
A = [6.1;6.04;5.98;5.92;5.86;5.8;5.74;5.69;5.63;5.57;5.52;5.46;5.41]
A = 13×1
6.1000 6.0400 5.9800 5.9200 5.8600 5.8000 5.7400 5.6900 5.6300 5.5700
N = 0.05;
B = round(A/N)*N
B = 13×1
6.1000 6.0500 6.0000 5.9000 5.8500 5.8000 5.7500 5.7000 5.6500 5.5500

추가 답변(0개)

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by