Skip to main content
10-Marble
Sep 27, 2011 12:02 PM UTC
Solved

trap errors individually in calculation of vector/matrix

Hi,

say I have a vector v with possible zero valued elements and I want log(v), is there an efficient way to get Mathcad to trap errors individually? In my case I simply want to return a predetermined constant -ve value for all zero elements.

At the moment I have something like "-100 on error log(v)" which returns a scalar if any element is zero rather than a vector. I know I could loop through but this might be slow since some of my arrays are quite big.

Regards,

D

RichardJAnswer
19-Tanzanite
Sep 27, 2011 2:11 PM UTC

I thought maybe vectorize would work.

It does if you use it as a function.

4 replies

23-Emerald I
Sep 27, 2011 12:16 PM UTC

I thought maybe vectorize would work.

Need a three line program

Translate
1-Visitor
Sep 27, 2011 12:46 PM UTC

I find it a little strange that the on error doesn't work when vectorized.

Mike

Translate