help-octave
[Top][All Lists]
Advanced

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

Re: counting totals in square grids (meshgrid)


From: Isak Delberth Davids
Subject: Re: counting totals in square grids (meshgrid)
Date: Mon, 14 Dec 2009 09:30:19 +0000

Yes --- thanks I could not expressed it better --- thats what I want.
Indeed, x=0 and x<1 is tautology, I should have written x>=0 and x<1.
I can now do this:

for i = 1:n
        for j = 1:n
                grid(i,j) = sum (i-1 <= x & x < i & j-1 <= y & y < j)
        end
end

Now, how will I extract the total x values in a given grid? I fail to
get the index k into the picture!

isak (I see I am a real nOOb)



2009/12/14 Jaroslav Hajek <address@hidden>:
> On Mon, Dec 14, 2009 at 8:41 AM, Isak Delberth Davids
> <address@hidden> wrote:
>> I would like to use the boundaries of the x-y grids, such that for
>> example all numbers in the interval:
>>
>> x=0 and x<1 & y=0 and y<1 are counted as the total count of say grid-1.1
>> x=1 and x<2 & y=0 and y<1 are counted as the total count of say grid-2.1
>> x=2 and x<3 & y=0 and y<1 are counted as the total count of say grid-3.1
>> .
>> .
>> .
>> x=n and x<n+1 & y=0 and y<1 are counted as the total count of say grid-n.1
>> .
>> .
>> .
>> x=0 and x<1 & y=1 and y<2 are counted as the total count of say grid-1.2
>> x=0 and x<1 & y=2 and y<3 are counted as the total count of say grid-1.3
>> x=0 and x<1 & y=3 and y<4 are counted as the total count of say grid-1.4
>> .
>> .
>> .
>> x=0 and x<1 & y=n and y<n+1 are counted as the total count of say grid-1.n
>> .
>> .
>> .
>> and so on. I hope that makes it a bit clearer ...
>>
>>
>> isak.davids
>
> Huh? x=0 and x<1 is a tautology (the first implies the second) ...?
>
> If I understand correctly, you have two vectors, x and y, of length m,
> and you want to compute an nxn matrix grid so that
> grid(i,j) is the count of indices k=1..m such that i-1 <= x(k) < i &&
> j-1 <= y(k) < j
> In octavish,
> grid(i,j) = sum (i-1 <= x & x < i & j-1 <= y & y < j).
>
> for all i,j=1:n.
>
> Is this correct?
>
> --
> RNDr. Jaroslav Hajek
> computing expert & GNU Octave developer
> Aeronautical Research and Test Institute (VZLU)
> Prague, Czech Republic
> url: www.highegg.matfyz.cz
>



-- 
***************************************************
***************************************************

FULL NAME: Isak Delbert Davids
LOCATION: mostly within 10cm of a keybord
CONTACTS: do not use contact lenses yet
FAX: still has a paper jam

"Views and opinions expressed by my person, are not necessarily true
--- they are simply my views and opinions"

***************************************************
***************************************************


reply via email to

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