필터 지우기
필터 지우기

How to get brushed data point index from Plot?

조회 수: 22 (최근 30일)
MJ
MJ 2021년 7월 30일
편집: Adam Danz 2021년 8월 3일
The following linked post was incredibly helpful for me but I would like to know how to obtain the indicies of the brushed data. I'm not sure why, but the size of Pos and the size of brush are different. I want to obtain the indicies in Pos of the brushed data. Thank you.
Handle = plot3(Pos(:,1),Pos(:,2),Pos(:,3), 'o');
axis equal;
view(0,90)
brush on
Select the required data and run the following to get the brushed points:
xd = get(Handle, 'XData');
yd = get(Handle, 'YData');
zd = get(Handle, 'ZData');
brush = get(Handle, 'BrushData');
brushed_x = xd(logical(brush));
brushed_y = yd(logical(brush));
brushed_z = zd(logical(brush));
figure, plot3(brushed_x, brushed_y, brushed_z, 'o');

채택된 답변

Adam Danz
Adam Danz 2021년 7월 31일
편집: Adam Danz 2021년 8월 3일
Continuing from your code...
brushedPoints = [brushed_x(:), brushed_y(:), brushed_z(:)];
dist = pdist2([xd(:),yd(:),zd(:)], brushedPoints);
[~, idx] = min(dist)
idx(i) is the index for brushedPoints(i,:).

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by