data extraction from f06 file

9 ビュー (過去 30 日間)
Milind Amga
Milind Amga 2022 年 6 月 29 日
コメント済み: Mathieu NOE 2022 年 7 月 4 日
Can anyone help me out in extracting the data highlighted in yellow? The data highlighted is part of matrix of order 5X5. Each line of data is a column of the matrix, for example, the first highlighted data line is the first column of a 5X5 matrix and each data point consists of a real part and a imaginary part seperated by comma.
I am attaching the file here (link removed later) for reference and the data other than that is of no use right now.
If you could create 5X5X16 matrices from the data (a seperate matrix for real part and a seperate matrix for imaginary part) that would be great.
Thanks in advance!

採用された回答

Mathieu NOE
Mathieu NOE 2022 年 6 月 29 日
hello my friend
here you are
the result is stored in Result_c
clc
clearvars
fileID = fopen('flutter_2d_rh_wing_base.f06');
Raw = textscan(fileID, '%s%[^\n\r]', 'Delimiter', '', 'WhiteSpace', '', 'ReturnOnError', false);
Raw = string(strtrim(Raw{1}));
Line1 = contains(Raw, "MATRIX QHH");
Line1 = find(Line1) + 3;
Line2 = contains(Raw, "THE NUMBER OF NON-ZERO TERMS");
Line2 = find(Line2) - 1;
Line2(Line2<Line1(1)) = [];
Take = false(size(Raw,1),1);
for i = 1:numel(Line1)
ind = Line1(i):3:Line2(i); % every 3 lines
Take(ind) = true;
end
Out = Raw(Take);
Out = regexprep(Out, ',', ' ');
% fill a 5x5x16 matrice
count1 = 0;
count2 = 1;
for ci = 1:size(Out,1)
if count1>4
count1 = 0;
count2 = count2 +1;
end
count1 = count1 +1;
tmp = split(Out(ci,1),' ');
tmp = tmp(2:end); % remove "1)"
tmp = tmp(strlength(tmp) > 0);
tmp = str2double(tmp);
Result_c(:,count1,count2) = tmp(1:2:end) + 1i*tmp(2:2:end); % real + j*imaginary part (comma separated values)
end
  2 件のコメント
Milind Amga
Milind Amga 2022 年 6 月 30 日
Thankyou sir ! Everything works right.
Mathieu NOE
Mathieu NOE 2022 年 7 月 4 日
as always, my pleasure !

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

タグ

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by