Info
此问题已关闭。 请重新打开它进行编辑或回答。
Extracting entries from vector B that are best estimate each entry in vector A
1 次查看(过去 30 天)
显示 更早的评论
Hi there.
I have two vectors, A & B.
A is of length 10, while B will always be of longer length (let's say 20 for this case).
I would like to extract the entries from B that best estimate each entry in A. Therefore, I want to finish up with B being of length 10.
Any help would be much appreciated!
0 个评论
回答(2 个)
Sean de Wolski
2011-1-25
A = 1.6:11;
B = 1:20;
[junk, idx] = min(bsxfun(@(x,y)abs(x-y),A.',B),[],2);
C = B(idx);
0 个评论
此问题已关闭。
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!