how can I give an entry order numbers and letters together and after reading only their numbers for doing?
such as
x=input('alpanub')
x=100a50b
y=100
c=50

2 Kommentare

Run the following code, it may give you some insight
name = input('Enter with input: ','s');
name_binary = isletter(name);
idx = find(name_binary == 0);
str2num(name(idx))
Stephen23
Stephen23 am 25 Okt. 2018
>> s = '100a50b';
>> v = sscanf(s,'%d%*c')
v =
100
50

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Akira Agata
Akira Agata am 25 Okt. 2018

1 Stimme

How about the following?
str = input('Enter with input: ','s');
c = regexp(str,'\d+','match');
output = str2double(c);

Weitere Antworten (0)

Kategorien

Mehr zu Get Started with MATLAB finden Sie in Hilfe-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