I am new in this community so forgive me if this is a sort of re-post. I am trying to convert this MATLAB script:
v_i = find(rect_xmin <= Xv & Xv <= rect_xmax & rect_ymin <= Yv & Yv <= rect_ymax)
in Mathematica. What it does (or at least it seems so to me) is to find the element positions in the two column vectors, Xv and Yv, satisfying the specified criteria. What I did so far is this:
intx = DeleteCases[
Flatten[Position[Xv, _?(xrectmin <= # <= xrectmax &)]], 1];
inty =
DeleteCases[Flatten[Position[Yv, _?( yrectmin <= # <= yrectmax &)]],
1];
pointpos = Intersection[intx, inty];
But it results in a vector of 800 elements, while there should be 400. Could you help me to understand what is wrong? Thank you!
Position[xv, x_ /; xrectmin <= x <= xrectmax]
, and similarly foryv
? I'm not really clear on what theFlatten
andDeleteCases
are for... $\endgroup$ – aardvark2012 Oct 4 '17 at 10:09Xv
Yv
,xrectmin
andyrectmin
; what output precisely are you looking for) because that code will give you the positions of the elements that satisfy the conditions. If that's not what you want, please be clear what you do want. $\endgroup$ – aardvark2012 Oct 4 '17 at 12:15