필터 지우기
필터 지우기

about moving datacursor in color plot

조회 수: 1 (최근 30일)
Ki
Ki 2013년 10월 9일
댓글: Ki 2013년 10월 9일
I am using matlab to plot a false color map and trigger the data cursor, I found that if the map is n-by-n (square), I can use the up/down/left/right arrow to move the data cursor to the next point and show the tip, but if the map is not square (n-by-m), then using up/down still can move it up or down but pressing left or right will cause the data cursor jumping, why's that?
function MyMain
M=rand(400, 600);
pcolor(M);
shading flat;
cursorMode = datacursormode(gcf);
datacursormode on;
set(cursorMode, 'UpdateFcn', {@myupdate, M});
end
function output_txt = myupdate(obj, event_obj, M)
pos = get(event_obj,'Position');
idx = get(event_obj, 'DataIndex');
val = M(idx);
output_txt = {['X: ',num2str(pos(1),10)], ['Y: ',num2str(pos(2),10)]};
if length(pos) > 2
val = M(idx);
output_txt{end+1} = ['VAL: ',num2str(val, 10)];
end
end
By the way, in above code, I pass the map to the callback function so to show the value at current position, but it is so slow if the data is big. Any way to the data cursor tip refer to the value without passing the whole matrix? Thanks.

답변 (1개)

Walter Roberson
Walter Roberson 2013년 10월 9일
For the second point, use a nested function that has access to M.
  댓글 수: 1
Ki
Ki 2013년 10월 9일
Hi Walter, Thanks for your reply. What does it mean by using nested function?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Graphics Performance에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by