Value associate to a parameter in a text

2 次查看(过去 30 天)
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?

采纳的回答

Paolo
Paolo 2018-7-9
编辑:Paolo 2018-7-9
data = fileread('mytextfile.txt');
val = regexp(data,'(?<=\s)(-?\d*\.?\d*)(?=\s|$)','match');
  7 个评论
Paolo
Paolo 2018-7-9
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.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Environment and Settings 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by