Hi,
I create a figure with toggle button on its toolbar by uitoggletool. The callback function for it is shown below:
function calc_slope(handle,event)
on = get(handle,'State');
if strcmpi(on,'on') || strcmpi(on,'off'),
xy=imline;
addNewPositionCallback(xy,@(xy)...
title(['\DeltaY/\DeltaX = ',num2str((xy(4)-xy(3))/(xy(2)-xy(1))),...
' [\DeltaX = ',num2str(xy(2)-xy(1)),', \DeltaY = ',num2str((xy(4)-xy(3))),']']));
end
As you can see, I'm trying to calculate the slope between two points on a curve. The code is something I found in the web that's pretty close to what I'm trying to. The 'addNewPositionCallback" is executed in both 'On' and 'Off' state, but it's merely a means to repeat the process as many times as a user wants. What I really want to do is number 4 and 5 below.
What I really want to do is as follows:
- "Draggable" points "snapped" to the nearest curve
- The connecting line shows
- Delta X, delta Y, and the slope provided in a "text box" drawn near the curve
- Draw as many lines as needed while in the 'On' state
- Delete all lines and 'text' boxes when toggle button is set to 'Off'
The imline function gives a bunch of features such as different line colors. I can care less on those. The major "wants" are the snapping and the text box.
Your help will be greatly appreciated.
Thank you,
Eric