data extraction from f06 file

14 visualizaciones (últimos 30 días)
Milind Amga
Milind Amga el 29 de Jun. de 2022
Comentada: Mathieu NOE el 4 de Jul. de 2022
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!

Respuesta aceptada

Mathieu NOE
Mathieu NOE el 29 de Jun. de 2022
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 comentarios
Milind Amga
Milind Amga el 30 de Jun. de 2022
Thankyou sir ! Everything works right.
Mathieu NOE
Mathieu NOE el 4 de Jul. de 2022
as always, my pleasure !

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Get Started with MATLAB en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by