I have a patch which I have included below and I want to add an additional ButtonDownFcn to the patch. When I do the second option the code does not work I get to many output arguments.
Original patch
for i = 1:10
counter = counter+1;
hpatch(counter) = patch([x(17) x(18) x(1) x(1)],[y(17) y(18) y(1) y(1)],[0 0 0 0],...
'Parent',hAx,'ButtonDownFcn', ['winopen(''' file(counter) ''');']));
end
New desired patch
for i = 1:10
counter = counter+1;
hpatch(counter) = patch([x(17) x(18) x(1) x(1)],[y(17) y(18) y(1) y(1)],[0 0 0 0],...
'Parent',hAx,'ButtonDownFcn', ['winopen(''' file(counter) ''');'],...
'ButtonDownFcn', @saveClickData(counter));
end
Here is the function
saveClickData(counter)
should it be this?:
saveClickData(source,event)
Try:
Then define the callback function as:
Make sure to define this function as a nested function, so that it has access to its parent function workspace including the
filevariable.