Trouble with custom data tip function (event)

조회 수: 2(최근 30일)
Roger Breton
Roger Breton 2022년 3월 7일
I am puzzled? I try to have a line drawn during the call to a custom text data tip function.
Here is the "normal" response, when clicking on a point with the mouse :
Here's the error message I get when I try to do the same mouse click while adding a few extra lines of code in the callback (first, a screen capture of the message, followed by the code :
Here is the code :
function txt = displayCoordinates(~, info)
global clickedCIE_L clickedCIE_a clickedCIE_b; % sorry for the globals abuse...
clickedCIE_L = info.Position(3); % 69
clickedCIE_a = info.Position(1); % -56
clickedCIE_b = info.Position(2); % 46
% handle_ligne = line([0 0],[clickedCIE_a clickedCIE_b],[0 0],'color',[0 0 1],'lineWidth',4);
DisplayAngle(clickedCIE_a, clickedCIE_b); <<< --------------------- This statement is causing the error?
Hrad = mod(atan2(clickedCIE_b,clickedCIE_a),2*pi); % 2.4539
hueAngle = Hrad*180/pi; % 140 degrés
chroma = sqrt(clickedCIE_a.^2 + clickedCIE_b.^2); % 72
txt = {sprintf('CIE L: %.0f', info.Position(3)), sprintf('CIE a: %.0f', info.Position(1)), sprintf('CIE b: %.0f', info.Position(2)), sprintf('CIE c : %.0f ', chroma), sprintf('CIE h : %.0f °', hueAngle) };
end
function DisplayAngle(a,b)
global clickedCIE_L clickedCIE_a clickedCIE_b;
a_start = 0;
b_start = 0;
a_end = clickedCIE_a
b_end = clickedCIE_b
% Delete existing marker, if any
if ~isempty(handle_ligne)
delete(handle_ligne);
end
handle_ligne = line([a_start a_end],[b_start b_end],[0 0],'color',[0.2 0.2 0.2],'lineWidth',4);
end
It does not matter whether I put the DisplayAngle function inline of not, I still get the error message.
Would there be any other approaches? All I'm trying to add to the figure is a line depicting the hue angle and chroma, at the bottom.
I'll continue looking around for the error on my own in case I find any solution... And I appreciate your precious help.

답변(0개)

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by