Last active
September 14, 2024 09:41
-
-
Save GarryLai/12de899c4102e6e94f7688dbbe23a179 to your computer and use it in GitHub Desktop.
NCU Rakit auto plot in background
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| echo "#####################" | |
| echo "# Rakit auto plot #" | |
| echo "# by GarryLai #" | |
| echo "#####################" | |
| echo "Running in background..." | |
| echo "Press Ctrl + C to exit." | |
| echo "" | |
| while true | |
| do | |
| #Do plot if .m file exist | |
| if [ $(ls -1 *.m 2>/dev/null | wc -l ) == 0 ] | |
| then | |
| #No files to plot | |
| sleep 1 | |
| else | |
| #Plot | |
| FILE=$(ls -tr *.m | head -n 1 | tail -1) | |
| echo ">>> $FILE" | |
| matlab -nodisplay -nosplash -nodesktop -r "try, run(['$FILE']), catch e, display(e.message), exit, end, exit" | |
| rm -f "$FILE" | |
| #Clean | |
| DAT=$(basename $FILE .m).dat | |
| rm -f $DAT 2>/dev/null | |
| DAT="${DAT:0:8}_*${DAT:8}" | |
| for f in $DAT | |
| do | |
| rm -f "${f}" 2>/dev/null | |
| done | |
| fi | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment