Matlab listeners multiple execution

I have an issue using Matlab listeners: PreGet and PostGet. My purpose is to be able to execute a set of functions when I am writing and when I am writing a calls property (before and after each read/write operation). This is an example of my class:
classdef myClass < handle
properties (GetObservable,SetObservable,GetAccess = public, SetAccess = public )
myProp = '';
end
methods
function myClass = myClass(Input)
myClass.myProp = Input;
addlistener(myClass , 'myProp' , 'PreGet' , @myClass.PreReadClass);
addlistener(myClass , 'myProp' , 'PreSet' , @myClass.PreSendClass);
addlistener(myClass , 'myProp' , 'PostGet' , @myClass.PostReadClass);
addlistener(myClass , 'myProp' , 'PostSet' , @myClass.PostSendClass);
end
end
methods (Hidden)
function PreSendClass(myClass, varargin)
disp('PreSet Executed')
end
function PostSendClass(myClass, varargin)
disp('PostSet Executed')
end
function PreReadClass(myClass, varargin)
disp('PreGet Executed')
end
function PostReadClass(myClass, varargin)
disp('PostGet Executed')
end
end
end
Matlab Run examples:
>> myTest = myClass(1);
myTest.myProp = 1;
PreSet Executed
PostSet Executed
>> myVar = myTest.myProp;
myVar
PreGet Executed
PostGet Executed
myVar =
1
Everything fine with this. I can execute my functions and get the results which I want. Though, I observed, that wen I use 'Tab Completion' feature from Matlab on 'myTest.myProp', PreGet and PostGet is executed, 4 times!! Sometimes 'myProp' is a dynamic structure and I am using Tab completion to access its fields.
myTest.myProp. % Use tab completion
PreGet Executed
PostGet Executed
PreGet Executed
PostGet Executed
PreGet Executed
PostGet Executed
PreGet Executed
PostGet Executed
Is it possible to prevent this from being executed 4 times? Or if not to prevent it at least to detect it and perform and action? I can run another function when tab completion is executed (e.g. display help or tool tip in command window).
Thank you!

댓글 수: 4

Sean de Wolski
Sean de Wolski 2013년 10월 9일
What release are you on? I am not able to reproduce this in 13b.
Florin
Florin 2013년 10월 9일
Sorry, I forgot to mention. I am on Matlab 2011b (7.13.0.54) 32bits. I had the same issue using Matlab 2009b.
Sean de Wolski
Sean de Wolski 2013년 10월 9일
If your Company/University's SMS is current you can upgrade to one of the newer releases at no additional cost.
Florin
Florin 2013년 10월 10일
Hello. Currently I am stuck with a 32 bits system. I made an update to Matlab 2012b and I did not like the performance. For the moment I would prefer to use 2011b

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

답변 (1개)

per isakson
per isakson 2013년 10월 9일
편집: per isakson 2013년 10월 11일

0 개 추천

I cannot reproduce the behavior you describe with R2013a. However, there might have been a bug although I don't find one in the Bug Report. (Not all bugs are in that list.)
.
2013-10-10
Did you ask the Matlab tech support?
There is a blog post at Undocumented Matlab on tab completion: Setting desktop tab completions

카테고리

도움말 센터File Exchange에서 Vibration Analysis에 대해 자세히 알아보기

제품

질문:

2013년 10월 9일

편집:

2013년 10월 11일

Community Treasure Hunt

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

Start Hunting!

Translated by