Groups | Search | Server Info | Login | Register


Groups > comp.soft-sys.octave > #59

loop-free comparison of different sized vectors

Newsgroups comp.soft-sys.octave
Date 2014-03-10 04:16 -0700
Message-ID <46e9236f-4049-4a39-86b4-094d25cbee12@googlegroups.com> (permalink)
Subject loop-free comparison of different sized vectors
From José Ignacio Royo Prieto <joseignacioroyoprieto@gmail.com>

Show all headers | View raw


Hello, everybody

I want to compare all the elements of two different sized vectors without using 'for' loops.

More precisely, if v and w are vectors of lengths n and m, respectively, 
I want to produce a matrix A of dimensions nxm such that 
A(i,j)=1 if v(i)>w(j) and 0 otherwise.

Of course, one can do that just using a loop going through all the elements of one of the vectors, something like

for i=1:length(v)
  A(i,:)=v(i)>w
end

but I was looking for a "vectorialized" Octave command to do it more efficiently. It is a pity that just typing v>w of v.>w Octave prompts an error, and does not do what I intend to ;-)

Thanks you all for your time and attention.
  

Back to comp.soft-sys.octave | Previous | NextNext in thread | Find similar


Thread

loop-free comparison of different sized vectors José Ignacio Royo Prieto <joseignacioroyoprieto@gmail.com> - 2014-03-10 04:16 -0700
  Re: loop-free comparison of different sized vectors peknott@arcor.de - 2017-06-07 21:59 -0700
    Re: loop-free comparison of different sized vectors Andreas Weber <info@tech-chat.de> - 2017-06-16 08:15 +0200

csiph-web