Read and save specific data from specific line

2 visualizaciones (últimos 30 días)
Ehsan Fatourehchi
Ehsan Fatourehchi el 7 de Nov. de 2016
Respondida: Jayaram Theegala el 11 de Nov. de 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)?

Respuesta aceptada

Jayaram Theegala
Jayaram Theegala el 11 de Nov. de 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.

Más respuestas (0)

Categorías

Más información sobre Data Import and Analysis en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by