From 47685529f47d63e7847410797d6197cd087b8a89 Mon Sep 17 00:00:00 2001
From: Antoine <antoine.hoffmann@epfl.ch>
Date: Wed, 20 Sep 2023 09:46:34 +0200
Subject: [PATCH] script to read fort.42 stream

---
 wk/read_fort42.m | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)
 create mode 100644 wk/read_fort42.m

diff --git a/wk/read_fort42.m b/wk/read_fort42.m
new file mode 100644
index 00000000..5101887f
--- /dev/null
+++ b/wk/read_fort42.m
@@ -0,0 +1,34 @@
+% 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')
-- 
GitLab