Read and save specific data from specific line
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Import and Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!