I have been receiving a warning message saying 'no regexp for "double"'. According to the warning message showed, it occurred at the line coded like this: notify(obj,event,myinput);
I can't figure out what triggered the warning since it's only the notify function. and myinput is a structure. I also have checked the code that calls notify(obj,event,myinput).
Appreciated if anyone can help!
No products are associated with this question.
Matlab fails to provide a meaningsful error message in this situation. It's left to the user to provide a work-around.
Here is a small example of my work-around. It is code from the on-ine help with a bit of error handling added together with code that causes an error: buf = 1; disp( buf(2) ). The trick is: try, overflowHandler_(eventSrc,eventData), catch me, disp(getReport(me)), end
%% sec = setupSEC; sec.prop1 = 5; sec.prop1 = 15;
returns to the command window
The value of Prop1 is overflowing! It's value was: 5 It's current value is: 15
Attempted to access buf(2); index out of bounds because numel(buf)=1. Error in overflowHandler>overflowHandler_ (line 13) disp( buf(2) ) Error in overflowHandler (line 3) overflowHandler_( eventSrc, eventData ) Error in SimpleEventClass/set.prop1 (line 14) notify( this,'Overflow',SpecialEventDataClass( org_value ) );
function sec = setupSEC % Create an object and attach the listener sec = SimpleEventClass; addlistener( sec, 'Overflow', @overflowHandler ) end
classdef SimpleEventClass < handle properties prop1 = 0; end events Overflow end methods function set.prop1( this, value ) org_value = this.prop1; this.prop1 = value; if ( this.prop1 > 10) % Trigger the event using custom event data notify( this, 'Overflow', SpecialEventDataClass( org_value ) ); end end end end
classdef SpecialEventDataClass < event.EventData properties OrgValue = 0; end methods function eventData = SpecialEventDataClass( value ) eventData.OrgValue = value; end end end
function overflowHandler( eventSrc, eventData ) try overflowHandler_( eventSrc, eventData ) catch me disp( getReport( me ) ) end end function overflowHandler_( eventSrc, eventData ) disp('The value of Prop1 is overflowing!') disp(['It''s value was: ' num2str( eventData.OrgValue )]) disp(['It''s current value is: ' num2str( eventSrc.prop1 )]) buf = 1; disp( buf(2) ) end
I use the same approach with code invoked by a timer. I've found it really helpful. See Debug code invoked by timer
First, review this link: http://blogs.mathworks.com/videos/2012/07/03/debugging-in-matlab/. Then step through your code with F10 (step over) and F11 (step into) until you see red text barfed up into the command window. Then you'll know what line it happened on. You can speed past sections of code by setting breakpoints. By the way, did you search your code for regexp?
What is class(event) ? It needs to be a string and you might get that warning if it was not.
The idea of notify(obj,event,myinput) is that MATLAB sends a signal to all objects that are listening for the event event. You will not find this object/callback by looking at your code in a linear manner. You want to look for where the listener was created. This is usually done with addlistener