How can I extract a certain numerical value from a text file?
Show older comments
I have run a model in a different program which has produced a large number of .txt files of output data.
I would like Matlab to open each file in turn and extract the value underneath "RF2" which is -4.2694476E+08 in the example below:
THE FOLLOWING TABLE IS PRINTED FOR NODES BELONGING TO NODE SET ASSEMBLY_SET-RF
NODE FOOT- RF1 RF2 RM3
NOTE
1 -1.3405922E+07 -4.2694476E+08 0.0000000E+00
MAXIMUM -1.3406E+07 -4.2694E+08 0.000
AT NODE 1 1 1
The number of interest is on Line 4379 of every text file. I have no problems getting the Matlab code to open each file, but I can't seem to get it to extract the correct number. I would like to jump to Line 4379, get the program to disregard the 1 and the -1.3405922E+07 and ONLY take the -4.2694476E+08. The value of this number of interest is different for each file so I can't just get MATLAB to search for "-4.2694476E+08" each time. The number is ALWAYS in the same place for each of the files.
Would anyone be able to point me to a way of getting MATLAB to extract this number? Many thanks
Accepted Answer
More Answers (0)
Categories
Find more on Data Import and Export in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!