# How to Convert 3D Data to 2D Using MATLAB

Written by chris daniels
• Share
• Tweet
• Share
• Pin
• Email

MATLAB is a technical software environment that allows you to import, manipulate and analyse 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.

Skill level:
Moderately Easy

## Instructions

1. 1

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.

my Data = zeros(100,10,8);

2. 2

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(my Data,100*10,8);

This function would return a 1,000-by-eight array with the first two dimensions combined.

3. 3

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.

better Array = squeeze(arrayWithSingletons);

4. 4

Analyse your data further as appropriate.

### Don't Miss

#### References

• All types
• Articles
• Slideshows
• Videos
##### Sort:
• Most relevant
• Most popular
• Most recent