필터 지우기
필터 지우기

Can't find where the warning msg is from

조회 수: 23 (최근 30일)
Mindy
Mindy 2013년 4월 24일
편집: per isakson 2017년 9월 29일
Hi everyone,
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!

답변 (4개)

per isakson
per isakson 2013년 4월 24일
편집: per isakson 2017년 9월 29일
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-line 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
Run
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 ) );
where
function sec = setupSEC
% Create an object and attach the listener
sec = SimpleEventClass;
addlistener( sec, 'Overflow', @overflowHandler )
end
and
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
and
classdef SpecialEventDataClass < event.EventData
properties
OrgValue = 0;
end
methods
function eventData = SpecialEventDataClass( value )
eventData.OrgValue = value;
end
end
end
and
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

Image Analyst
Image Analyst 2013년 4월 24일
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?
  댓글 수: 1
Daniel Shub
Daniel Shub 2013년 4월 25일
I am not sure that debugging callbacks in this way is really viable. I am not even sure how the event queue is handled when you are in debug mode. I am pretty sure if timers are involved that you would have a disaster on your hands.

댓글을 달려면 로그인하십시오.


Walter Roberson
Walter Roberson 2013년 4월 24일
What is class(event) ? It needs to be a string and you might get that warning if it was not.

Daniel Shub
Daniel Shub 2013년 4월 25일
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

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by