MATLAB Answers

Taking the nearest decimals possible

조회 수: 4(최근 30일)
I have a query
i have 2 number
1] 1.6778
2] 2.032
How do i take the number 1.6778 to 1.7 ( nearest value)
and 2.032 to 2.0 ?
Kindly help

  댓글 수: 0

Sign in to comment.

채택된 답변

Adam Danz
Adam Danz 22 Apr 2020
편집: Adam Danz 22 Apr 2020
Y = round(X,N) where N is the number of digits to the right (when positive) or left (negative).
y = round(X*10)/10;

  댓글 수: 3

Ganesh Kini
Ganesh Kini 22 Apr 2020
Thanks for the help
Ganesh Kini
Ganesh Kini 22 Apr 2020
So i have two values
A = 1.69 and B = 1.8
A = 2.1 and B = 2.4
How do i show it that they are approximately equal without using round
are there any relational operators that i can use?
Stephen Cobeldick
Stephen Cobeldick 23 Apr 2020
Either ismembertol or do it yourself by comparing the absolute difference against a tolerance limit:

Sign in to comment.

추가 답변(0개)


Translated by