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 CenterFile Exchange에서 Get 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