Value associate to a parameter in a text

1 vue (au cours des 30 derniers jours)
Jack
Jack le 9 Juil 2018
Commenté : Jack le 9 Juil 2018
So I have a text file similar to the following:
DELZZ 3301.23
KUTY 4.32 SERI -0.023
I want Matlab to read the file and return values associate to each parameter (DELZZ, KUTY,SERI,...) Any suggestion?

Réponse acceptée

Paolo
Paolo le 9 Juil 2018
Modifié(e) : Paolo le 9 Juil 2018
data = fileread('mytextfile.txt');
val = regexp(data,'(?<=\s)(-?\d*\.?\d*)(?=\s|$)','match');
  7 commentaires
Paolo
Paolo le 9 Juil 2018
That's right, you will need to use the greedy * quantifier rather than the + quantifier. Since you need to match those values too, use:
(?<=KUTY01\s)-?\d*\.?\d*
I'll update my answer.
Jack
Jack le 9 Juil 2018
Thank u so much

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Text Data Preparation dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by