-1

I have a 4D array in matlab something like this,

test(:,:,1,1) =

     0


test(:,:,2,1) =

     0


test(:,:,3,1) =

     0


test(:,:,4,1) =

     0


test(:,:,5,1) =

     0


test(:,:,1,2) =

     0


test(:,:,2,2) =

     0


test(:,:,3,2) =

     0


test(:,:,4,2) =

     0


test(:,:,5,2) =

     0


test(:,:,1,3) =

     0


test(:,:,2,3) =

     0


test(:,:,3,3) =

     0


test(:,:,4,3) =

     0


test(:,:,5,3) =

     0


test(:,:,1,4) =

     0


test(:,:,2,4) =

     0


test(:,:,3,4) =

     0


test(:,:,4,4) =

     0


test(:,:,5,4) =

     0


test(:,:,1,5) =

     0


test(:,:,2,5) =

     0


test(:,:,3,5) =

     0


test(:,:,4,5) =

     0


test(:,:,5,5) =

     0

K>> test

test(:,:,1,1) =

     0


test(:,:,2,1) =

     0


test(:,:,3,1) =

     0


test(:,:,4,1) =

     0


test(:,:,5,1) =

     0


test(:,:,1,2) =

     0


test(:,:,2,2) =

     0


test(:,:,3,2) =

     0


test(:,:,4,2) =

     0


test(:,:,5,2) =

     0


test(:,:,1,3) =

     0


test(:,:,2,3) =

     0


test(:,:,3,3) =

     0


test(:,:,4,3) =

     0


test(:,:,5,3) =

     0


test(:,:,1,4) =

     0


test(:,:,2,4) =

     0


test(:,:,3,4) =

     0


test(:,:,4,4) =

     0


test(:,:,5,4) =

     0


test(:,:,1,5) =

     0


test(:,:,2,5) =

     0


test(:,:,3,5) =

     0


test(:,:,4,5) =

     0


test(:,:,5,5) =

     0

Now I want to get an array, something like this

ans =

     0     0     0     0
     0     0     0     0
     0     0     0     0
     0     0     0     0
     0     0     0     0

Is there a simple way to convert the dimentions. I am very much new to multidimensional arrays in Matlab. Please let me know if anyone knows of any solution.

cppiscute
  • 707
  • 2
  • 10
  • 33

1 Answers1

1

Use the squeeze function, it will return a matrix of size [5 4] when you input a matrix of size [1 1 5 4]

Daniel
  • 36,610
  • 3
  • 36
  • 69
  • Thanks for the answer. Let me know if you happen to know the same modification with the help of reshape command, that would be one more help. Regards – cppiscute Feb 05 '16 at 14:08
  • If you take a look at the question marked as duplicate (top of this page) you can find an example in one of the answers. – Daniel Feb 05 '16 at 14:09