Turning all elements of a column array into the same factor of 10
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Saeid
il 20 Ago 2023
Commentato: John D'Errico
il 20 Ago 2023
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)?
1 Commento
Risposta accettata
Image Analyst
il 20 Ago 2023
Modificato: Image Analyst
il 20 Ago 2023
Try round
X = [19.9, 20, 20, 20.1, 20.12, 19.81, 20, 32, 46];
rounded = round(X, -1)
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Resizing and Reshaping Matrices in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!