Kindly help to solve this task on getting the last digit of a string.

3 views (last 30 days)
How would you call this function in command window
If radius is equal last digit of your roll number, what is the result?
rollnumber=5612

Answers (2)

Image Analyst
Image Analyst on 18 Apr 2022
Here is one way (of many):
rollnumber=5612;
str = num2str(rollnumber)
str = '5612'
radius = str2double(str(end))
radius = 2

Star Strider
Star Strider on 18 Apr 2022
Another approach —
rollnumber=5612
rollnumber = 5612
lastDigit = rem(rollnumber, 10)
lastDigit = 2
.

Categories

Find more on MATLAB in Help Center and File Exchange

Tags

Products


Release

R2007b

Community Treasure Hunt

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

Start Hunting!