From edb8f997cb156468a535f50377a13575b8a1a4c7 Mon Sep 17 00:00:00 2001 From: Joseph Lizier Date: Tue, 17 Dec 2019 17:08:27 +1100 Subject: [PATCH] Added new loader file for 2D xls format to flocking analysis demo --- demos/octave/FlockingAnalysis/loadxls2d.m | 43 +++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 demos/octave/FlockingAnalysis/loadxls2d.m diff --git a/demos/octave/FlockingAnalysis/loadxls2d.m b/demos/octave/FlockingAnalysis/loadxls2d.m new file mode 100644 index 0000000..22e2ef9 --- /dev/null +++ b/demos/octave/FlockingAnalysis/loadxls2d.m @@ -0,0 +1,43 @@ +function [x,y] = loadxls3d(filename, properties) +% loadxls2d loads 2D fish data from an xls file where time increases down the +% rows and then across the columns we have 2 x,y position columns for each +% fish in turn, i.e.: +% , , , , , etc +% , , , , , etc +% +% Inputs: +% - filename - the name of the file to load +% - properties (not required) - properties object (may be required for other file loaders) +% Outputs: +% - x - 2D array, each row contains x position for each fish (in columns) +% - y - as per x + +%% +%% Java Information Dynamics Toolkit (JIDT) +%% Copyright (C) 2019, Joseph T. Lizier et al. +%% +%% This program is free software: you can redistribute it and/or modify +%% it under the terms of the GNU General Public License as published by +%% the Free Software Foundation, either version 3 of the License, or +%% (at your option) any later version. +%% +%% This program is distributed in the hope that it will be useful, +%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +%% GNU General Public License for more details. +%% +%% You should have received a copy of the GNU General Public License +%% along with this program. If not, see . +%% + + [data,txt,raw] = xlsread(filename); + + % Make sure we preprocess data to have x,y, as 2D arrays of x(timeStep, fishID): + + % timeSteps = size(data,1); % number of rows; not required + xFishIndex = 2 : 2 : size(data,2); % which indices are the x values for different fish + x = data(:,xFishIndex); + y = data(:,xFishIndex+1); + +end +