help-octave
[Top][All Lists]
Advanced

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

Re: Need to simplified a splitting and comparison commands


From: Juan Pablo Carbajal
Subject: Re: Need to simplified a splitting and comparison commands
Date: Thu, 13 Oct 2011 14:45:46 +0200

On Thu, Oct 13, 2011 at 10:39 AM, Faizal <address@hidden> wrote:
> Thank you Mr Juan for response.
>
> Yes I have a list of R of 100 random integers and I need to split it into
> "n" size of frame (in my example is n=5) and no I did not have definite
> interval. I just split it into frame as shown in my example.
> Also yes I need to do intersect between frame to find common numbers. If it
> has no common number it will show 0 or it will stop if next intersection is
> empty. and the end result it will display common number.  So that is what I
> want to achieve.  If there is a function or loop or if command I can use to
> simplified to get the result I want.
> Below is the illustration diagram that I want to built.  Hope this
> explanation is clear to you or other the reader
>
> http://octave.1599824.n4.nabble.com/file/n3900899/tree_matrix.jpg
>
> Thank you
>
> --
> View this message in context: 
> http://octave.1599824.n4.nabble.com/Need-to-simplified-a-splitting-and-comparison-commands-tp3896923p3900899.html
> Sent from the Octave - General mailing list archive at Nabble.com.
> _______________________________________________
> Help-octave mailing list
> address@hidden
> https://mailman.cae.wisc.edu/listinfo/help-octave
>

I still do not understand why you need to do 2 list comparison. You
could do 1st against 2nd, result against 3rd, result against 4th..and
so on until result is empty or there are no more lists.

Lets say you organized your k lists into one matrix M of n-by-k where
n is the length of the lists (assuming they are all equal, if not pad
with NaN or a negative number or whatever is not among your random
integers).
That is the i-th list is M(:,i).

Then you can do

result = M(:,1);
for i = 2:k
  r = intersect (result, M(:,i));

  if isempty ( r )

    break
  end

  result = r;
end

if
-- 
M. Sc. Juan Pablo Carbajal
-----
PhD Student
University of Zürich
http://ailab.ifi.uzh.ch/carbajal/


reply via email to

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