How can I write a function that takes one scalar input(tens or ones place) and it prints the name of the value?

5 views (last 30 days)
What I intend is to use the MATAB built-in-function floor to determine if the number is a whole number, and it can also be employed to determine the value of the digit in the tens place and the value in the ones place.

Answers (1)

Rafael Müller
Rafael Müller on 5 Mar 2018
Hi Paul
I suggest using
mod(x,1) == 0
Instead of `floor` because it detects NaN and Inf as not whole number. Finally to get the digits use the following code:
tenPlace = floor(x/10)
oncePlace = rem(x, 10)

Community Treasure Hunt

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

Start Hunting!