Drexel dragonThe Math ForumDonate to the Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: How to retrieve the given column of the data of arbitrary size?
Replies: 7   Last Post: Nov 18, 2012 6:14 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]

Posts: 93
Registered: 11/30/09
Re: How to retrieve the given column of the data of arbitrary size?
Posted: Nov 13, 2012 9:54 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <k7tg96$lq8$1@newscl01ah.mathworks.com>...
> "Ha" wrote in message <k7qprc$h2m$1@newscl01ah.mathworks.com>...
> >
> > For instance, A is a 10x10x10x10 matrix, the 3rd column of the 2nd dimension of A is given by squeeze(A(:,3,:,:)). What if the size of A is arbitrary? A could be 10x10, 5x10x5, 10x10x5x5x10, ..., or anything else. How to write a function applicable to arbitray A?

> A = rand(2,3,4,5);
> n = ndims(A);
> ind(1:n) = {':'};
> ind{2} = 3; % ind = {':' 3 ':' ':' }
> A3=squeeze(A(ind{:}))
> % Bruno

Haha. I have writen a function in this manner.

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2015. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.