Discretization of multidimensional signal implementaion issue
===

[Symbolic Aggregate Approximation][1] talks about converting a time series (x,t) into symbols. Based on this,I have few basic queries. What if the time signal is a composite of (x,y,z,t) representing position coordinates or simply (x,y,t) for 2 dimensional image with a time stamp t. Following is the amazing solution according to [Reply][2] posted by [User][3] (Steps1. perform SAX for each dimension 2. do cartesian product and then do SAX for the result). The issue lies in the cartesian product,SAX does not do the symbolization after cartesian product.So,how to go about it?

 1. Do SAX for each dimension stored in dataSAX(:,dim) where dim=3


The result obtained is 

    dataSAX =
    
         1     1     3
         1     1     3
         1     1     3
         2     2     3
         3     3     2
         3     3     2
         2     3     1
         2     3     2
         2     3     2
         2     3     2
         2     2     3
         2     2     3
         2     1     2
         2     1     1
         2     2     1
         3     1     1
         3     2     1
         3     1     1
         1     1     2
         1     1     1


 2. Find cartesian product and then do SAX of the resultant. It is here that lies the issue. It is giving a single vector of similar data all 1's

    V =
    
         1
         1
         1
         1
         1
         1
         1
         1
         1
         1
         1
         1
         1
         1
         1
         1
         1
         1
         1
         1


Then how do I use this tool to assign symbols/discretize. It can be downloaded from [here][4]Please help.  


  function [sax_string] = sax_demo(data)
    
        if nargin == 0
         
    data_len      = 256;
            x = random_walk(data_len);
              y = random_walk(data_len);
               z = random_walk(data_len);
          
            
         
        else
            data_len      = length(x);
        end
         nseg =20;      %# size of alphabet (a,b,c)
       
        alphabet_size = 3;
    
        if alphabet_size > 10
            disp('Currently alphabet_size cannot be larger than 10.  Please update the breakpoint table if you wish to do so');
            return;
        end
        
        data_len
        nseg
        
        % nseg must be divisible by data length
        %if (mod(data_len, nseg))
            
          %  disp('nseg must be divisible by the data length. Aborting ');
         %   return;  
            
        %end;
    
        % win_size is the number of data points on the raw time series that will be mapped to a 
        % single symbol
        win_size = floor(data_len/nseg)
        %win_size=1;
       x = (x - mean(x))/std(x);
       y = (y - mean(y))/std(y);
       z = (z - mean(z))/std(z);
       %plot(data);
         
           
        % special case: no dimensionality reduction
       
      
    dataSAX = zeros(nseg,3);
    
        dataSAX(:,1) = timeseries2symbol(x, data_len, nseg, alphabet_size)
    
      dataSAX(:,2) = timeseries2symbol(y, data_len, nseg, alphabet_size)
      dataSAX(:,3) = timeseries2symbol(z, data_len, nseg, alphabet_size)
    
    
        % map the segments to string
        %str = timeseries2symbol(data, data_len, nseg, alphabet_size);
        
      
        
        color = {'g', 'y', 'm', 'c'};
        symbols = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'};
        
        
    %    sax_string = symbols(str);
    dataSAX(1,:);
    
    %# build cartesian product of all combinations of the A=3 symbols
    [p q r] = ndgrid(1:alphabet_size,1:alphabet_size,1:alphabet_size);
    cartProd = [p(:) q(:) r(:)];
    
    %# map to the new alphabet with 3*3*3 = 27 symbols
    [V] = ismember(dataSAX, cartProd, 'rows')
    
    %# A to Z with $ character to make up 27 symbols
    oldSymbols = {'a';'b';'c'};             %# 1: a, 2: b, 3: c
    newSymbols = cellstr(['A':'Z' '$']');   %# 1: A, ..., 26: Z, 27: $
    
    %# SAX representation of the entire time series as a string
    mappedV = char(newSymbols(V))'
    map=timeseries2symbol(cartProd, data_len, nseg, alphabet_size)
    sax_str=newSymbols(map)
    
    function r = random_walk(n)
  
    sigma=1;
    r=[0 cumsum(sigma.*randn(1,n-1))]; % standard Brownian motion

The code returns a sequential representation mappedV=`ABCDEFGHIJKLMNOPQRST` which is not what I had in mind.Further,the variable sax_str returns an  Empty cell array: 0-by-20. Please help how to go about it.


  [1]: https://sites.google.com/a/seninp.net/trajectory/algorithms/sax
  [2]: http://stackoverflow.com/questions/11660823/discretization-of-3dimensional-signals
  [3]: http://stackoverflow.com/users/97160/amro
  [4]: http://www.cs.ucr.edu/~eamonn/SAX.htm