Clear Filters
Clear Filters

Read and save specific data from specific line

2 views (last 30 days)
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)?

Accepted Answer

Jayaram Theegala
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.

More Answers (0)

Categories

Find more on Large Files and Big Data 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!