Extract Text From Nastran f06 file

7 ビュー (過去 30 日間)
Nicolas Jalbert
Nicolas Jalbert 2017 年 11 月 16 日
コメント済み: KSSV 2017 年 11 月 17 日
Hi all,
I am looking to extract specific data from a Nastran f06 file (it opens as a text file in Notepad++).
What I want to do:
1- Locate the title "MODAL PARTICIPATION FACTORS" (here in the example it is at lign 37, but will vary depending on the analysis... therefore why I want to locate the title).
2- Locate the end of the table. It ends with a blank entry followed by a "Total" header. (here in the example at lign 254)
3- Extract all the data into one matrix. It starts 5 entry lines after the "Participation Factors" title, this is a fixed feature in all .f06 analysis. So here it would be a 211x8 type of matrix. The columns being "Mode N°" "Frequency" "T1" .. to .."R3"
Would you guys have any idea how to do this? Thanks in advance. I attach the file to this post.
Nicolas

採用された回答

KSSV
KSSV 2017 年 11 月 16 日
fid = fopen('NASTRAN_file.txt') ;
S = textscan(fid,'%s','delimiter','\n') ;
S = S{1} ;
fclose(fid) ;
str1 = 'MODAL PARTICIPATION FACTORS' ;
str2 = 'TOTAL' ;
idx1 = find(contains(S,str1))
idx2 = find(contains(S,str2))
  6 件のコメント
Nicolas Jalbert
Nicolas Jalbert 2017 年 11 月 16 日
Thanks that would be great! An other problem I have now is that even after cell2mat for a specific line of data, there is no division between the values.. therefore I can't manipulate them or use them in specific operations afterwards.
I'm trying to figure out a way
KSSV
KSSV 2017 年 11 月 17 日
fid = fopen('NASTRAN_file.txt','r') ;
tline = fgetl(fid);
iwant = zeros([],8) ;
count = 0 ;
while ischar(tline)
tline = fgetl(fid);
if ~isempty(str2num(tline))
count = count+1 ;
iwant(count,:) = str2num(tline) ;
end
if contains(tline,'TOTAL')
break
end
end
fclose(fid) ;

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeText Data Preparation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by