Select specific digits of a number
304 次查看(过去 30 天)
显示 更早的评论
How can I select specific parts of a number?
For example if we have x=953, I want to select specifically the first digit (or the last two) and save it in another variable, so the outcome would be y=9 (or y=53)
Thanks
0 个评论
采纳的回答
更多回答(3 个)
Petorr
2019-4-12
c = 123.45
for d = [0.01 0.1 1 10 100]
round( (mod(c,10*d)-mod(c,d))/d )
end
[round() is needed because of binary precision]
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!