Home > chronux > spectral_analysis > helper > change_row_to_column.m

# change_row_to_column

## PURPOSE

Helper routine to transform 1d arrays into column vectors that are needed

## SYNOPSIS

function data=change_row_to_column(data)

## DESCRIPTION

``` Helper routine to transform 1d arrays into column vectors that are needed
by other routines in Chronux

Usage: data=change_row_to_column(data)

Inputs:
data -- required. If data is a matrix, it is assumed that it is of the
form samples x channels/trials and it is returned without change. If it
is a vector, it is transformed to a column vector. If it is a struct
array of dimension 1, it is again returned as a column vector. If it is a
struct array with multiple dimensions, it is returned without change
Note that the routine only looks at the first field of a struct array.

Ouputs:
data (in the form samples x channels/trials)```

## CROSS-REFERENCE INFORMATION

This function calls:
This function is called by:

## SOURCE CODE

```0001 function data=change_row_to_column(data)
0002 % Helper routine to transform 1d arrays into column vectors that are needed
0003 % by other routines in Chronux
0004 %
0005 % Usage: data=change_row_to_column(data)
0006 %
0007 % Inputs:
0008 % data -- required. If data is a matrix, it is assumed that it is of the
0009 % form samples x channels/trials and it is returned without change. If it
0010 % is a vector, it is transformed to a column vector. If it is a struct
0011 % array of dimension 1, it is again returned as a column vector. If it is a
0012 % struct array with multiple dimensions, it is returned without change
0013 % Note that the routine only looks at the first field of a struct array.
0014 %
0015 % Ouputs:
0016 % data (in the form samples x channels/trials)
0017 %
0018
0019 dtmp=[];
0020 if isstruct(data);
0021    C=length(data);
0022    if C==1;
0023       fnames=fieldnames(data);
0024       eval(['dtmp=data.' fnames{1} ';'])
0025       data=dtmp(:);
0026    end
0027 else
0028   [N,C]=size(data);
0029   if N==1 || C==1;
0030     data=data(:);
0031   end;
0032 end;```

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