Mapping 2 vectors - help to vectorize

前端 未结 6 1164
情话喂你
情话喂你 2020-11-30 12:34

Working in Matlab I have 2 vectors of x coordinate with different length. For example:

xm = [15 20 24 25 26 35 81 84 93];
xn = [14 22 26 51 55 59 70 75 89 96         


        
6条回答
  •  南笙
    南笙 (楼主)
    2020-11-30 13:14

    Your xm and xn are sorted. If this is generally the case, then you can do much better than stepping over the entire array.

    For each value in xn, there will be a range of values for which a value in xm will be closer to that number than any other. Compute these intervals beforehand and you can then step through both arrays sequentially.

提交回复
热议问题