How to extract numerical values as a table from an .out (text) file ?
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I am using an old Fortan based solver for CFD analysis. The output from the software is an .out text file. I want to know how to extract the useful values from this text file. From the attached file I would like to extract values of x,y,z and s0 for different Mach Numbers and angle of attacks. The useful values start in the row 761, and are further characteristized for different mach numbers and angle of attacks. I would like the code to extract the value of mach number and angle of attack, and x, y, z and s0 for every mach number and angle of attack.
Risposte (1)
Moksh
il 27 Set 2023
Modificato: Moksh
il 29 Set 2023
Hi Abhishek,
I understand that you have performed a CFD analysis and obtained the resulting data in “.txt” format. Now you are looking to extract the data relevant to you which starts from line 761.
You can try utilizing the “fopen” and “textscan” functions in MATLAB, which opens a text file and reads it into a “cell array” respectively. Additionally, you can specify conversion specifiers in “textscan” function to match the data while reading.
For an example, you can try implementing the data into a cell array where each index corresponds to that line in the text file using the above-mentioned functions.
Please refer to the following code snippet and use the path for "data.txt" in the "fopen" function:
% Reading the sample text file
fid = fopen('data.txt');
% Reading the text data inside the file
s = textscan(fid, '%s', 'Delimiter','\n');
% s now contains the file in cell-array format
s = s{1};
% Displaying data on line 761
disp(s{761})
Extraction of the relevant data can now be achieved by simply looping over the cell array.
For more information, please refer to the following documentation:
- fopen: https://in.mathworks.com/help/matlab/ref/fopen.html
- textscan: https://in.mathworks.com/help/matlab/ref/textscan.html
Hope this helps in resolving the issue you were facing.
Best Regards,
Moksh Aggarwal
0 Commenti
Vedere anche
Categorie
Scopri di più su Text Data Preparation in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!