Read and save specific data from specific line
2 views (last 30 days)
Show older comments
Ehsan Fatourehchi
on 7 Nov 2016
Answered: Jayaram Theegala
on 11 Nov 2016
Hi all,
I have an output punch file from Nastran. I need to read and save specific numbers from specific lines. I can open and save the punch file with textscan command. It saves the whole data in one column. See the below line as an example. '-CONT- -1.237426E-03 8760' Referring to this example, does anyone know how can I save the middle number (-1.237426E-03)?
0 Comments
Accepted Answer
Jayaram Theegala
on 11 Nov 2016
I understand that you want to save the middle number in your string. Assuming that all the data follow the same format, the middle number can be extracted by using “strsplit” function, since the number has a space on both sides.
strs = strsplit('-CONT- -1.237426E-03 8760', ' ');
numString = strs(2);
num = str2double(numString);
Hope this helps.
0 Comments
More Answers (0)
See Also
Categories
Find more on Data Import and Analysis 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!