2013-12-16 1 views
1

datacursor에서 커서 위치 값을 얻으려면 어떻게해야합니까? 여기에 내가 POS를 얻기 위해 수정 function output_txt에 시도 내 코드GUI에서 datacursor의 가치를 얻는 방법 Matlab

filename = handles.loadDataName; 
x=importdata(filename,' ',indexend); 
fid = fopen(filename,'r'); 
A = textscan(fid,'%f%f','Delimiter',' ','headerLines',indexstart); 
data = cat(2,A{:}); 
time = data(:,1); 
c1 = data(:,2); 
plot(handles.axes_grafik,time,c1) 
grid on; 
dcm = datacursormode(gcf); 
datacursormode on; 
set(dcm, 'updatefcn', @myfunction) 


function output_txt = myfunction(~,event_obj) 
dataIndex = get(event_obj,'DataIndex'); 
pos = get(event_obj,'Position'); 
output_txt = {[ 'Time: ',num2str(pos(1),5)] ....., 
    ['Amplitude: ',num2str(pos(2),5)]}; 

입니다 (1) 및 순위 (2) 전역 변수로, 나는 '정의 힌트 문자열 기능에서 오류'

을 말한다 그림에 오류가 발생했습니다

pos (1)과 Pos (2)를 검색하여 editbox에 표시하려고합니다. 이 일을 할 수있는 방법이 있습니까? 감사합니다

+0

'myfunction'을 디버그 모드로 실행하고 작동하는지 확인 했습니까? "오류 메시지"는 일반적으로 정확합니다. 아마도 'myfunction'에서 뭔가 잘못되었을 수 있습니다 ... 예 : 'disp (output_txt);'를 추가하고 정말로 원하는 메시지가 표시되는지 확인하십시오. – sebastian

답변

1

[x,y] = ginput

이 명령은 다음의 XY 좌표를 반환 Enter 키를 누르 때까지 u는 원하는 u는 여러 번 UR 그림을 클릭하게됩니다.