Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

MATLAB Multidimensional Array

  1. Sep 1, 2009 #1

    I'd like to access a column of values from the 4th dimension of a 4D Double array in MATLAB and then save them to a new matrix.

    For example:

    A = rand(3,3,3,3);

    gives me:

    ans(:,:,1,1) =

    ans(:,:,1,2) =

    ans(:,:,1,3) =

    I want to create a new matrix, B, with those values but specifying B = A(1,1,1,:) results in the same output above. I want a vector in this form:


    Thank you!
  2. jcsd
  3. Sep 1, 2009 #2
    Your use of the colon operator is incorrect. See the Matlab docs on this subject for an explanation of how to subscript an array in the way you want.
  4. Sep 1, 2009 #3
    Just put squeeze in front.

  5. Sep 1, 2009 #4
    Thanks, Matonski. Squeeze does the trick!
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Similar Threads - MATLAB Multidimensional Array Date
How to program this in Matlab Feb 28, 2018
Matlab Making a short test for self-adjointness Feb 23, 2018
Matlab Plotting Coordinate Transformations in Matlab Feb 12, 2018
Matlab Replace NaN with next element in Multidimensional Array Apr 6, 2016