LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Matlab script error handling

Solved!
Go to solution

Hello!

 

I am using Labview 2012 SP1 and I wrote a Matlab scipt to draw a Gaussian fit curve on a histogram graph.

In some extreme conditions, the shape of the histogram prevents the Gaussian fit to be succesfully calculated and Matlab throws an error (see attachment) displayed in a popup.

The error is perfectly understandable, but I would like to trap it and avoid the pop up to appear.
I wired the error out so that the error text is showed in a proper Labview field, the Gaussian curve is not drawn and any code serially following doesn't execute.

However, the popup still appears.

Is there a way to avoid it?

 

Thank you!

Best regards.

Michela

 

0 Kudos
Message 1 of 3
(3,847 Views)
Solution
Accepted by topic author MG70

Is it something you can recover from easily? If so, use Unbundle By Name to unbundle your error cluster.  From there, you can wire the numeric into a case structure.  With that, you can have two cases: one with the error code and the other as default.  With the error code case, you place a "Clear Errors" Vi inside and wire the error cluster into that and out the other side.  In the default case, you wire the error straight through.  That way, you only clear this one type of error.

 

In 2014 or newer, the Clear Errors VI takes a numeric input to skip all of the case structure fun.  But, it's the same result.  You clear the error you expect and can handle.  There's almost always a way to write your own error handling.  It just depends on what exactly you need to do to recover from the error.

0 Kudos
Message 2 of 3
(3,816 Views)

Thank you for the suggestion! I think this is the best way to go.

 

Michela

0 Kudos
Message 3 of 3
(3,524 Views)