필터 지우기
필터 지우기

How to round a decimal to 4 digits

조회 수: 150 (최근 30일)
Luki
Luki 2017년 1월 22일
답변: Walter Roberson 2017년 1월 22일
angle = Phi_intrp(ismembertol(round(s1*10^4)/10^4,s2));
So I am given a table Phi_intrp, which I can evaluate at every entry of s1.
s1 = transpose(-27:0.0001:2)
so it is a very large array. I want to evaluate Phi_intrp at every entry of s2, however. s2 contains measurement data, decimals with 4 digits after the dot. All entries of s2 are within the range of s1. So I figured, when I round the entries of s1 to 4 digits after the dot, I should be able to use the code line mentioned at first to evaluate Phi_intrp at the desired values. It is not working, however. And the
round(s1*10^4)/10^4
does not round the entries to 4 digits after the dot either.
What am I doing wrong?

채택된 답변

Image Analyst
Image Analyst 2017년 1월 22일
Pass 4 into round():
>> r=rand
r =
0.383306318625529
>> r4 = round(r, 4)
r4 =
0.3833

추가 답변 (1개)

Walter Roberson
Walter Roberson 2017년 1월 22일
ismembertol(A, B, 1e-4,'Datascale',1)

카테고리

Help CenterFile Exchange에서 Numeric Types에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by