How to round numbers to specific near point?

2 Ansichten (letzte 30 Tage)
Triveni
Triveni am 22 Jun. 2022
Beantwortet: Stephen23 am 22 Jun. 2022
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.

Akzeptierte Antwort

Stephen23
Stephen23 am 22 Jun. 2022
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

Weitere Antworten (0)

Kategorien

Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange

Produkte


Version

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by