extract the number with only the first decimal number

조회 수: 3 (최근 30일)
Alberto Acri
Alberto Acri 2023년 9월 20일
댓글: Alberto Acri 2023년 9월 20일
I have to extract the number with only the first decimal number
Examples:
1.23 -> 1.2
2.49 -> 2.4
4.77 -> 4.7
7.51 -> 7.5
  댓글 수: 2
Dyuman Joshi
Dyuman Joshi 2023년 9월 20일
Extract as in? Do you want to store it in string/char/cell array of character vectors?

댓글을 달려면 로그인하십시오.

채택된 답변

Cris LaPierre
Cris LaPierre 2023년 9월 20일
I'd look into fix or floor.
V = [1.23, 2.49, 4.77, 7.51];
v1 = floor(V*10)/10
v1 = 1×4
1.2000 2.4000 4.7000 7.5000
v2 = fix(V*10)/10
v2 = 1×4
1.2000 2.4000 4.7000 7.5000

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Multirate Signal Processing에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by