can Matlab send out alert email/message if certain variable exceed the threshold?

14 views (last 30 days)
please help. So I can set up a monitoring/alert function while the program keep processing the data stream.

Answers (3)

Jan
Jan on 27 Feb 2011

Andreas Goser
Andreas Goser on 27 Feb 2011
Yes.
Depending on what your data stream is - I see this can be done by a "timer object" and the SENDMAIL command.

Walter Roberson
Walter Roberson on 28 Feb 2011
Although Andrea's answer sounds plausible, it does not meet your requirement that the alert or email be sent while Matlab continues to process your data stream. The interval during which Matlab pauses in the processing might not be very long, but as you did not describe a maximum delay, we must assume that any pause is unacceptable.
In order for there not to be any delay in the processing, you would need to be running at least two threads.
You might expect that that running another thread could be done by using the Java interface to start another thread, but all Java communications with Matlab must be done through the single original Matlab engine thread -- and thus each check of the value would have to pause the processing for at least a little delay.
You might expect that if you had the Parallel Processing Toolkit that you could do this through multiple threads. You would not be able to do it through PARFOR, but SPMD mode is not out of the question. Unfortunately, it is known that some kinds of I/O must be handled through the original thread, so the interaction with the operating system to send the email or alert might have to be launched from the original thread. We can infer from your question that you are also doing I/O to get more data in continually, and those two interactions might temporarily clash, causing a delay in processing your data. I have not located a discussion of what kind of I/O can be served in parallel threads and what cannot, so potentially the combination would be feasible in your situation... maybe... if you had the Parallel toolbox...
On the other hand, as you did not give details about what you are trying to do, I can speculate that you might be collecting data via a serial interface or A/D board. Both of those data sources can be (and commonly are) set up with a buffer that will continue to accumulate data while Matlab runs. If that is your set up, then probably launching an alert or email will not take so much time that your buffer would overflow, and you could process you accumulated data without any being lost. You would, in that case, only have problems if your program is "hard real time" with very narrow timing tolerances -- but if it is then you should not be using plain Matlab and should instead be using Real Time Workshop.
  2 Comments
Hello Blower
Hello Blower on 5 Mar 2011
thank you.
Yes, any pause/delay is acceptable so far, I can afford quite large tolerance indeed, as long as the processing can resume after sending the alert/email. The incoming data is the stock price which retrieve from Yahoo.
what is the simplest way to do it?
Walter Roberson
Walter Roberson on 5 Mar 2011
Andreas' suggestion of sendmail, http://www.mathworks.com/help/techdoc/ref/sendmail.html should generally work, as should the FEX submission that Jan refers you to. You may find that you need to set the name of the server that will handle the mail transmission; doing so is described in the Tips section of the sendmail command.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!