Octave compare two arrays -


given 2 column vectors,i need compare each element of vector first element of vector b in first iteration , return logical array. second element of vector b each element of vector , return logical array forth. number of logical arrays equal number of elements in vector b.

a=1:10; b=[5 6 7]; j=1:length(b),  i=1:10,     c=b(j)==a(i);   end; end;     

ex: after first iteration of inner loop need return [0 0 0 0 1 0 0 0 0 0]

try this:

a = 1:10 b = [5 6 7] output = zeros(3,10); = 1:length(b)     output(i,:) = (a == b(:,i)) %  b(:, i) meas using index value end   output =     0   0   0   0   1   0   0   0   0   0    0   0   0   0   0   1   0   0   0   0    0   0   0   0   0   0   1   0   0   0 

Comments

Popular posts from this blog

amazon web services - S3 Pre-signed POST validate file type? -

c# - Check Keyboard Input Winforms -