MATLAB is a technical software environment that allows you to import, manipulate and analyze large amounts of data. In many cases, it your data will be highly dimensional, having three or more dimensions. Converting high-dimensional data to lower dimensions can allow your analysis to be easier and analysis algorithms to run more efficiently. MATLAB contains built-in function for altering the dimensionality of data.
Import your data or create a test array. The following code creates a three-dimensional array of zeros in the form of repeated recordings from eight data channels. Each recording is 100 timepoints long and repeated 10 times.
myData = zeros(100,10,8);
Convert the dimensionality of the array using the reshape function. To combine the 10 trials for each channel in the above example, use the following code:
myNewData = reshape(myData,100*10,8);
This function would return a 1,000-by-eight array with the first two dimensions combined.
Remove singleton dimensions using the squeeze function. Although this is not always necessary, after manipulating your data you may be left with a dimension of length one, called a singleton dimension. The following code would remove singleton dimensions from an array.
betterArray = squeeze(arrayWithSingletons);
Analyze your data further as appropriate.
- Photo Credit Thinkstock Images/Comstock/Getty Images