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: very large array
Replies: 18   Last Post: Jun 26, 2013 2:53 AM

Advanced Search

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

Posts: 8
Registered: 6/24/13
Re: very large array
Posted: Jun 24, 2013 11:11 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"Lorenzo Quadri" <quadrilo_sub_r@gmail.com> wrote in message <kq9n1f$smu$1@newscl01ah.mathworks.com>...
> "Steven_Lord" <slord@mathworks.com> wrote in message
> >
> > Not only will this be slow, it will also error. If you have a 10 row array:
> >
> > xv = (1:10).';
> > X = [xv, xv.^2]
> > size(X)
> >
> > and you delete one row, you now have a 9 row array:
> >
> > X(3, :) = []
> > size(X)
> >
> > In your code, length(dati) is NOT evaluated each time the loop body executes
> > but is fixed when the loop STARTS executing. Thus you'd walk off the end of
> > the array if any of the rows are deleted.
> >
> > So you want to eliminate rows whose sum is less than 355 and whose maximum
> > and minimum elements are more than 20 apart? Use logical indexing on the
> > whole array at once rather than row-by-row. Compute along the rows by
> > specifying a dimension input argument to SUM and RANGE.
> >
> > rowsums = sum(dati, 2, 'double');
> > rowranges = range(dati, 2);
> > dati(rowsums < 355 & rowranges > 20, :) = [];
> >
> > While you could do this all on one line, I broke the two conditions out so
> > you could experiment with a smaller dati to prove to yourself that it works
> > and that you understand what the code is doing.
> >
> > --
> > Steve Lord
> > slord@mathworks.com
> > To contact Technical Support use the Contact Us link on
> > http://www.mathworks.com

>
> Yes, thank you, your comment is right,
> I replaced the for loop with a while one
> like:
>
> a=length(dati)
>
> while (a>0)
> if((sum(dati(i,:))<355) & range(dati(i,:))>20)
> a = a - 1;
> dati(i,:) = [];
> end
> end
>
> I'll try evaluate it with logical indexing as you suggested.
> Copy the array in an other one take about 1,5 hrs every 1000000 iterations
> so the whole operation is exstimated in about 300 hrs or 12,5 days (too much, conditions change meanwhile).
>
>
> thank you very much


ops sorry

while (a>0)
if((sum(dati(i,:))<355) & range(dati(i,:))>20)
dati(i,:) = [];
end
a = a - 1;
end



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.