Extract number on variable name.

My variable name is Final_50000_run_1
Is there a way to extract the number 50000 and 1 out.
Thanks.

2 comentarios

Matt J
Matt J el 19 de Jul. de 2016
Yes, there is, but how did those numbers get there in the first place?
Laura
Laura el 19 de Jul. de 2016
I saved it for different run of simulations in Fortran.

Iniciar sesión para comentar.

Respuestas (2)

Azzi Abdelmalek
Azzi Abdelmalek el 19 de Jul. de 2016
Editada: Azzi Abdelmalek el 19 de Jul. de 2016
s='Final_50000_run_1'
regexp(s,'\d+','match','once')
If you want to extract all the numbers
regexp(s,'\d+','match')
Steven Lord
Steven Lord el 19 de Jul. de 2016

1 voto

Is this a variable name or a file name? If it is a variable name, I recommend you read question 1 in the Programming section of the FAQ for an explanation of why including data in your variable names is discouraged. If it is a file name, see Azzi's answer.

Categorías

Más información sobre Fortran with MATLAB en Centro de ayuda y File Exchange.

Preguntada:

el 19 de Jul. de 2016

Respondida:

el 19 de Jul. de 2016

Community Treasure Hunt

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

Start Hunting!

Translated by