Convert an integer into a decimal number

조회 수: 105 (최근 30일)
Riccardo Tronconi
Riccardo Tronconi 2021년 10월 21일
편집: KSSV 2021년 10월 21일
Hi guys I'm struggling with such a dummy problem.
I have a variable m=2 and I would like to convert it into m=0.2
Is there a way to do that?

채택된 답변

KSSV
KSSV 2021년 10월 21일
편집: KSSV 2021년 10월 21일
m=2
m = 2
m/10
ans = 0.2000
If your class of variable is int32 or int64 i.e. an integer. Then convert it to float using double.
m = int64(2)
m = int64 2
class(m)
ans = 'int64'
m = double(m)/10
m = 0.2000

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by