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 remove variable number of rows in each column of a matrix
Replies: 6   Last Post: Nov 3, 2013 1:14 AM

Advanced Search

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

Posts: 8,102
Registered: 6/7/07
Re: How to remove variable number of rows in each column of a matrix
Posted: Nov 2, 2013 1:11 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

On 11/1/2013 11:03 PM, dpb wrote:
> On 11/1/2013 9:47 PM, bijan.mobasseri@gmail.com wrote:
>>
>>>
>>> What's the test for determining the starting point for each column?

>> -
>> They are available separately and known. Let 's say for the 10
>> columns I have 10 numbers. The problem is they are all different. If
>> they were the same I would just take off the top of the matrix.

>
> Then it's just
>
> result=dat(max(idvec):max(idvec)+499,:);
>
> You'll want to test that max()+499<length(dat) of course...


Actually, that isn't what you really wanted...probably a case where a
simple loop is as efficient as any other solution...

res=zeros(500,size(dat,2)); % preallocate
for ix=1:length(idvec)
res(:,ix)=dat(idvec:idvec+499,ix);
end

accumarray() can do it but probably not any faster than the explicit loop

Again, of course, need the error checking...

--




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

[Privacy Policy] [Terms of Use]

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