Return index from Plot3 using getCursorInfo(dcm_obj);

조회 수: 1 (최근 30일)
Willem
Willem 2013년 3월 12일
I am trying to figure this out. I have a 3d plot (x,y,z) in a GUIDE created GUI and I need to retrieve the DataIndex using the datacursor. I've used this in 2d plots and it works well but for some reason it will only ever return a value of 1.
% --- Executes on button press in pushbutton4. function pushbutton4_Callback(hObject, eventdata, handles) % hObject handle to pushbutton4 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) h = gcf; dcm_obj = datacursormode(h); info_struct = getCursorInfo(dcm_obj); set (handles.test_index,'str',info_struct.DataIndex);
Appreciate any help.
Thank you
Willem

답변 (1개)

ChristianW
ChristianW 2013년 3월 12일
Works for me:
function test
t = 0:pi/50:10*pi;
plot3(sin(t),cos(t),t)
uicontrol('Style', 'pushbutton','Callback',@pbcb)
datacursormode on
function pbcb(hObj,event)
dcm_obj = datacursormode(gcf);
info_struct = getCursorInfo(dcm_obj);
title(info_struct.DataIndex);

카테고리

Help CenterFile Exchange에서 Data Exploration에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by