Find position of specific digit in a number
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Inna Pelloso
am 28 Mär. 2023
Bearbeitet: Inna Pelloso
am 28 Mär. 2023
Hi,
I have A = [123; 312]. How can I find the position of the digit 3 in each element of A? That is, I want B = [3; 1].
Any help would be appreciated.
IP
1 Kommentar
Akzeptierte Antwort
Walter Roberson
am 28 Mär. 2023
A = [123; 312]
B = cell2mat(strfind(string(A), '3'))
This will fail if any entry does not have exactly one 3. And watch out for floating point data, string() will round it.
1 Kommentar
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!