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!