m-file to find elements (text) in an alloy

1 visualización (últimos 30 días)
Majid Vaghari
Majid Vaghari el 7 de Sept. de 2020
Comentada: Majid Vaghari el 7 de Sept. de 2020
I need a MATLAB m-file to find elements and their ratio in an alloy. The input and output are shown in the below table:
For example input is ‘Al0.1Co0.25Cu14’ then the code gives output:
If there is any other information you need let me know.
Best
M. Vaghari
  2 comentarios
Walter Roberson
Walter Roberson el 7 de Sept. de 2020
That does not have anything to do with plotting ??
Hint: regexp() . You have a pattern which is a series of non-empty alphabetic characters, followed by a possibly-empty series of non-alphabetic characters
Majid Vaghari
Majid Vaghari el 7 de Sept. de 2020
Thank you.

Iniciar sesión para comentar.

Respuesta aceptada

Stephen23
Stephen23 el 7 de Sept. de 2020
>> str = 'Al0.1Co0.25Cu14AaBb';
>> [mat,spl] = regexp(str,'[A-Z][a-z]*','match','split');
>> vec = str2double(spl(2:end));
>> vec(isnan(vec)) = 1
vec =
0.1000 0.2500 14.0000 1.0000 1.0000
>> mat
mat =
'Al' 'Co' 'Cu' 'Aa' 'Bb'

Más respuestas (0)

Categorías

Más información sobre Data Import and Export en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by