# How to convert a multidimensional matrix into 2D ?

3 visualizzazioni (ultimi 30 giorni)
Risposto: Santosh Fatale il 15 Dic 2022
I have a 101x101x101 matrix. In order to plot it, I need to convert it to 2D. How can this be done ?
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Risposte (1)

Santosh Fatale il 15 Dic 2022
There are multiple options to do so.
Option 1: Use the "reshape" function
• You can change the matrix dimension by using the "reshape" function. Note that, "reshape" function reads elements of matrix columnwise first and then row-wise for reshaping it. For more information, you can check the documentation for "reshape".
Option 2: Write a simple code, as below, to stack matrices one after another.
NewA = zeros(101*101, 101); % A is original matrix.
% Here I am stacking 2-D matrices after one another with respect to the third
% dimension
for idx3 = 1 : 101
NewA(1+((idx3-1)*101):(idx3*101),:) = A(:,:,idx3);
end
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Categorie

Scopri di più su Matrices and Arrays in Help Center e File Exchange

R2015a

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by