how to find the position of a given number

Risposte (3)

José-Luis
José-Luis il 5 Set 2012
Modificato: José-Luis il 6 Set 2012
your_answer = strfind(num2str(1050),num2str(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 Commenti

Thanks Image Analyst !! What would be the code if the input is not a string?
see answer by Jose-Luis
locationOfDigit = strfind(num2str(yourFullNumber), num2str(yourDesiredDigit))

Accedi per commentare.

Categorie

Prodotti

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by