From: John on
Hello,

I would like to have one of my matlab scripts automatically called when
another script calls the plot function.

What is the easiest way to obtain that?

Is it possible to create a listener which will listen for "plot events" and
upon detection of such an event call a function defined by me?

Thanks!



From: Sean on
"John" <John(a)yabadabadooo.com> wrote in message <4bd022d5$0$274$14726298(a)news.sunsite.dk>...
> Hello,
>
> I would like to have one of my matlab scripts automatically called when
> another script calls the plot function.
>
> What is the easiest way to obtain that?
>
> Is it possible to create a listener which will listen for "plot events" and
> upon detection of such an event call a function defined by me?

You could write a new function 'my_plot()' which calls plot directly and then calls you other script.

function my_plot(varargin)
plot(varargin)
my_script();
end
From: Steven Lord on

"John" <John(a)yabadabadooo.com> wrote in message
news:4bd022d5$0$274$14726298(a)news.sunsite.dk...
> Hello,
>
> I would like to have one of my matlab scripts automatically called when
> another script calls the plot function.

_Instead of_ or _in addition to_ the PLOT function?

> What is the easiest way to obtain that?

The easiest way would be to define your own myplot function and call that
instead of PLOT, as Sean suggested. If that's not an option, my next
attempt would be to create your own subfunction or private function named
plot -- then the "definition" of PLOT would only change for the functions in
the function file containing that subfunction or the functions in the parent
directory of the private directory containing your private plot function
rather than for all MATLAB functions.

Just out of curiosity, why are you trying to intercept PLOT calls? What are
you trying to have your other script do when PLOT is called? Perhaps
there's a way to do what you want directly (like if you want to change a
property of the figure or axes, you could change the default property value
and so have the figure/axes be created using the new default property
value.)

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ