Hello everyone, I'm using Matlab 2007b with GUIDE and I'm creating plot handles during a button callback. For those plots (just points), I want to create a context menu that allows the user to delete a specific point. So when you right click them and click on the context option "delete", the point is deleted and some user data is removed and stored again. This works. However I'd like to also include a function execution in the callback to an already existing function another button uses. Sadly the function isn't known to that handle, or maybe I can't figure it out correctly. I'll try to illustrate this in an example:
% GUIDE functions:
function varargout = WPE_Developer(varargin)% some stuff
%
function WPE_Developer_OpeningFcn(hObject, eventdata, handles, varargin)% stuff etc.
%function MY_CALLBACK(hObject, eventdata, handles, varargin)% function which is called from a button click, x and y_matrix are example values
y_matrix = [1 2 3 4 5 6;1 2 3 4 5 6;1 2 3 4 5 6];x = [10000, 20000, 30000];%for j = 1:size(y_matrix,1) for k = 1:size(y_matrix, 2) clear temp cmenu callbackstring; temp = plot(x(j), y_matrix(j,k),'b.'); cmenu = uicontextmenu; set(temp, 'uicontextmenu', cmenu); callbackstring = [... %CALLBACK STRING 'handles = guidata(gcbf);'... sprintf('handles.DATA.%s.%s(%d,%d) = NaN;', CarID_Name, y_get, j, k)... ...'project_changed(true, handles);'... 'guidata(gcbf,handles);'... 'delete(gco);']; uimenu(cmenu, ... 'Label', sprintf('Delete Point (%06.0f|%06.2f)', x(j), y_matrix(j, k)), ... 'Callback', callbackstring); % THIS IS THE CALLBACK OF DELETING
endend%function project_changed(true, handles)% THIS function is unknown as a callback from the point handles above
My current code (5k lines, so I don't want to put everything here) works. Just when activating line
...'project_changed(true, handles);'...
project_changed isn't known to the point handle which I DO understand. The error is the following:
??? Undefined function or method 'project_changed' for input arguments of type 'struct'.??? Error while evaluating uimenu Callback
Is there a way to solve this and make the function "to be known during the callback"? Splitting it into multiple .m files is not the solution I want. I found things with @-calls and some callback properties, but I don't seem to find a solution.
I'd appreciate any help, thanks.
Best Answer