help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How do I replace this for-loop?


From: Robert Macy
Subject: Re: How do I replace this for-loop?
Date: Sat, 05 Jul 2008 20:44:28 -0700

THANK YOU!

I downloaded a copy of hist2d from the URL you gave me and
it works great.

Robert


On Sat, 5 Jul 2008 15:54:51 -0400
 Rob Mahurin <address@hidden> wrote:
> On Jul 4, 2008, at 5:48 PM, Robert Macy wrote:
> > What's the best way to replace this for-loop?
> >
> > Given an array, n, of datapoints, such that:
> >
> >>> size(n)
> > rows = 27000
> > columns = 2
> >
> > where n(:,1) are all the integer x values, and
> > n(:,2) are all the integer y values,
> > both integer values are in the range of 1 to 101
> >
> > I slowly did it this way:
> >
> > output=zeros(101,101);
> > for i=1:27000
> >   output( n(i,1),n(i,2) ) = output( n(i,1),n(i,2) ) +
> 1;
> > endfor
> 
> Well, there's hist2d :)
>
http://octave.svn.sourceforge.net/viewvc/octave/trunk/octave-forge/
> 
>
main/plot/inst/hist2d.m?revision=HEAD&content-type=text/plain
> 
> >
> > as you all know this is fairly slow.
> > What's a simple way to replace this for-loop?
> >
> > Robert
> >
> > _______________________________________________
> > Help-octave mailing list
> > address@hidden
> > https://www.cae.wisc.edu/mailman/listinfo/help-octave
> 
> 
> 
> -- 
> Rob Mahurin
> Dept. of Physics & Astronomy
> University of Tennessee       phone: 865 207 2594
> Knoxville, TN 37996           email: address@hidden
> 
> _______________________________________________
> Help-octave mailing list
> address@hidden
> https://www.cae.wisc.edu/mailman/listinfo/help-octave



reply via email to

[Prev in Thread] Current Thread [Next in Thread]