summaryrefslogtreecommitdiff
path: root/matlab/prep.sh
diff options
context:
space:
mode:
authorWarrick Lo <warrick.s.z.lo@gmail.com>2026-02-11 07:16:45 -0800
committerWarrick Lo <warrick.s.z.lo@gmail.com>2026-02-11 07:16:45 -0800
commitf1a9a85c6138715c3933c957c695d0482b901154 (patch)
treef2d6ca37aa60eb35737f31a4a8ab3a202e07f01c /matlab/prep.sh
Finish lab report up to Task 2B
Signed-off-by: Warrick Lo <warrick.s.z.lo@gmail.com>
Diffstat (limited to '')
-rw-r--r--matlab/prep.sh26
1 files changed, 26 insertions, 0 deletions
diff --git a/matlab/prep.sh b/matlab/prep.sh
new file mode 100644
index 0000000..a2def48
--- /dev/null
+++ b/matlab/prep.sh
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+# Prepare all waveform data for MATLAB processing.
+#
+# This script will:
+# 1. sanitise the header before running MATLAB's readtable();
+# 2. convert line endings from DOS to UNIX; and
+# 3. rename files to have *.tsv file extensions.
+#
+# This script assumes all waveform data is tab-delimited and
+# stored in *.txt files.
+#
+# Usage: ./prep.sh
+
+files=$(ls -- *.txt)
+
+for i in $files; do
+ printf "Converting %s\n" "$i"
+
+ # Replace the header and convert DOS line endings (CRLF)
+ # to UNIX line endings (LF).
+ sed -i -e "1c time\tv1\tv2\tv3\ti1\ti2\ti3" -e "s/\x1D$//" "$i"
+
+ # Rename files to have TSV extensions.
+ mv "$i" "${i%.*}.tsv"
+done