Skip to content
Snippets Groups Projects
Commit 47685529 authored by Antoine Cyril David Hoffmann's avatar Antoine Cyril David Hoffmann :seedling:
Browse files

script to read fort.42 stream

parent b4ff4118
No related branches found
No related tags found
No related merge requests found
% Define the file path
file_path = [resdir,'fort.42']; % Replace 'your_file.txt' with the actual file path
% Open the file for reading
fileID = fopen(file_path, 'r');
% Check if the file was opened successfully
if fileID == -1
error('Failed to open the file.');
end
% Initialize an empty array to store the data
data__ = [];
% Read the data from the file line by line
while ~feof(fileID)
% Read a line from the file
line = fgetl(fileID);
% Convert the line to a numeric value and append it to the data array
value = str2double(line);
% Check if the conversion was successful
if ~isnan(value)
data__ = [data__; value];
end
end
% Close the file
fclose(fileID);
% Display the stored data
figure;
plot(data__,'o')
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment