From 257ef285d3cb4430c4e978a90cdc16a678c49d98 Mon Sep 17 00:00:00 2001 From: jlizier Date: Wed, 30 Aug 2017 15:39:59 +1000 Subject: [PATCH] Added a Matlab utility function to save CA data in a (relatively) efficient data format, since Matlab will only save doubles for ascii format. --- demos/octave/CellularAutomata/saveCA.m | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 demos/octave/CellularAutomata/saveCA.m diff --git a/demos/octave/CellularAutomata/saveCA.m b/demos/octave/CellularAutomata/saveCA.m new file mode 100644 index 0000000..34d0f9d --- /dev/null +++ b/demos/octave/CellularAutomata/saveCA.m @@ -0,0 +1,16 @@ +% +% Utility function to save raw CA data to a text file format. +% Unfortunately MAtlab's -ascii format only writes full doubles, making much larger files than we need. +% So I wrote this. + +function saveCA(filename, caStates) + + warning('off','MATLAB:Java:DuplicateClass'); + javaaddpath('../../../infodynamics.jar'); + addpath('..'); + + arrayWriter = javaObject('infodynamics.utils.ArrayFileWriter'); + arrayWriter.makeIntMatrixFile(octaveToJavaIntMatrix(caStates), filename); + +end +