필터 지우기
필터 지우기

Read and save specific data from specific line

조회 수: 2 (최근 30일)
Ehsan Fatourehchi
Ehsan Fatourehchi 2016년 11월 7일
답변: Jayaram Theegala 2016년 11월 11일
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)?

채택된 답변

Jayaram Theegala
Jayaram Theegala 2016년 11월 11일
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개)

카테고리

Help CenterFile Exchange에서 Large Files and Big Data에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by