Selecting specific number in place value of hunredth

조회 수: 12 (최근 30일)
Nurul Hazira
Nurul Hazira 2021년 4월 21일
답변: Prabhan Purwar 2021년 5월 5일
Hi! I need help, I've been looking a proper function to use but I don't get any, please help me I can't find a way to solve this. Let say I have a number 365 (and I want it to write a code that only read the most right digit which is 5).
Regards, Nurul

답변 (1개)

Prabhan Purwar
Prabhan Purwar 2021년 5월 5일
Hi Nurul,
The individual digits in the number signify one's, ten's, hundred's, and thousand's position which could be obtained by dividing the number with the basis^(power of consideration) and getting remainder value by using mod function.
Kindly have a look at the following example code:
% For Natural numbers
x = 365;
floor(mod(x/1,10)) %unit's place
ans = 5
floor(mod(x/10,10)) %hundred's place
ans = 6
floor(mod(x/100,10)) %thousand's place
ans = 3
Hope it helps!
Thanks

카테고리

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

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by