Filter löschen
Filter löschen

how to write a character from a string?

2 Ansichten (letzte 30 Tage)
Arman Kam
Arman Kam am 2 Feb. 2013
Hi I didn't use commands for strings in matlab so i have a word like 'displacement22' and i want to write '22' from this string, so what would i do?

Antworten (3)

Image Analyst
Image Analyst am 2 Feb. 2013
s = 'displacement22' % Your string.
theNumber = sscanf(s, 'displacement%d') % Extract the number.

Azzi Abdelmalek
Azzi Abdelmalek am 2 Feb. 2013
Bearbeitet: Azzi Abdelmalek am 2 Feb. 2013
s='displacement22' ;
out=s(regexp(s ,'[0-9]'))
%or
out=s(regexp(s ,'\d'))

Jan
Jan am 2 Feb. 2013
s = 'displacement22';
s = strrep(s, 'displacement', '');

Kategorien

Mehr zu Characters and Strings finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by