Use addNewPositionCallback to updates stored line coordinates in GUIDE
1 次查看(过去 30 天)
显示 更早的评论
Hello all,
I have read everything I could about the use of Callbacks in GUIDE, but I may use a little help from experienced users. I am trying to update a handles every time I resize an imline line, so I can use their coordinates later in my program. I cannot find the correct way to word it in Matlab. Here is an extract of the code:
handles.h = imline(gca,[-1 -1],[-2 2]);
id = addNewPositionCallback(handles.h,@hpos);
% Update handles structure
guidata(hObject, handles);
function hpos(h,handles)
% Display image info
set(handles.iminfo, 'String',{['It works!']});
I get the following error message: "Error while evaluating Figure WindowButtonMotionFcn.
Not enough input arguments."
Anybody could guide me in the right direction? Thanks in advance!
0 个评论
采纳的回答
Greg
2018-2-21
From the documentation:
addNewPositionCallback — Add new-position callback to ROI object
id = addNewPositionCallback(h,fcn) adds the function handle fcn to the list of new-position callback functions of the ROI object h. Whenever the ROI object changes its position each function in the list is called with the syntax:
fcn(pos)
where pos is of the form returned by the object's getPosition method.
The return value, id, is used only with removeNewPositionCallback.
This indicates that only 1 input is being passed to hpos, and you've define it to require 2 inputs. I'm not sure it'll work, but I would try:
handles.h = imline(gca,[-1 -1],[-2 2]);
id = addNewPositionCallback(handles.h,{@hpos,handles.iminfo});
% Update handles structure
guidata(hObject, handles);
function hpos(pos,iminfo_obj)
% Display image info
set(iminfo_obj, 'String','It works!');
% I'm assuming 'It works!' is a placeholder and you want to use pos above
2 个评论
更多回答(0 个)
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!