Matlab conditional maximum without modifying vector -
suppose have vector of floating point numbers. call x.
usually if want largest number in x, can call matlab function max(x).
however, suppose want largest number, excluding indices in vector, specified in other vector.
the straightforward way (and way in c) loop through vector , keep updating max, while skipping index in second vector. say, linear search maximum , skip indices not want.
however, wonder if there's way more conventional in matlab solve problem.
slicing vector/matrix logical index way go:
http://blogs.mathworks.com/steve/2008/01/28/logical-indexing/
sounds have indices, turn around logical index this:
exclude = [ ... ]; include = ones(size(x)); include(exclude) = 0; max_m = max(x(include));
Comments
Post a Comment