Home > chronux > spectral_analysis > helper > check_consistency.m

check_consistency

PURPOSE ^

Helper routine to check consistency of data dimensions

SYNOPSIS ^

function [N,C]=check_consistency(data1,data2,sp)

DESCRIPTION ^

 Helper routine to check consistency of data dimensions
 Usage: [N,C]=check_consistency(data1,data2,sp)
 Inputs:
 data1 - first dataset
 data2 - second dataset
 sp - optional argument to be input as 1 when one of the two data sets is
 spikes times stored as a 1d array.
 Outputs:
 Dimensions of the datasets - data1 or data2 (note that 
    routine stops with an error message if dimensions don't match - [N,C]
    N left empty for structure arrays

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [N,C]=check_consistency(data1,data2,sp)
0002 % Helper routine to check consistency of data dimensions
0003 % Usage: [N,C]=check_consistency(data1,data2,sp)
0004 % Inputs:
0005 % data1 - first dataset
0006 % data2 - second dataset
0007 % sp - optional argument to be input as 1 when one of the two data sets is
0008 % spikes times stored as a 1d array.
0009 % Outputs:
0010 % Dimensions of the datasets - data1 or data2 (note that
0011 %    routine stops with an error message if dimensions don't match - [N,C]
0012 %    N left empty for structure arrays
0013 N1=[]; N2=[];
0014 if nargin < 3 || isempty(sp); sp=0; end;
0015 if isstruct(data1);
0016     C1=length(data1);
0017 else
0018     [N1,C1]=size(data1);
0019 end;
0020 if isstruct(data2);
0021     C2=length(data2);
0022 else
0023     [N2,C2]=size(data2);
0024 end;
0025 if C1~=C2; error('inconsistent dimensions'); end;
0026 if sp==0;
0027    if ~isstruct(data1) && ~isstruct(data2);
0028       if N1~=N2; error('inconsistent dimensions'); end;
0029    end;
0030 end;
0031 N=N1; C=C1;

Generated on Fri 28-Sep-2012 12:34:30 by m2html © 2005