how to find the position of a given number
2 次查看(过去 30 天)
显示 更早的评论
if the input is 1050, whats the code to get the position of 5.....(answer is third)
0 个评论
回答(3 个)
Image Analyst
2012-9-5
locationOf5 = strfind('1050', '5')
You can adapt it to other numbers, or pass in string variables instead of hard-coding it if you want.
3 个评论
Image Analyst
2012-9-6
locationOfDigit = strfind(num2str(yourFullNumber), num2str(yourDesiredDigit))
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Characters and Strings 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!