Skip to main content
1-Visitor
May 24, 2013
Solved

Error creating matrix of 2 variable function - subsequently create contour plot

  • May 24, 2013
  • 2 replies
  • 2592 views

I am having issues creating a matrix of values from a 2 variable function and then plotting the matrix data in a contour plot.

Short script is attached; any input would be very appreciated.

Regards,

T.S.

Best answer by RichardJ

The matrix function always starts at 0,0, so you get a divide by zero. You would also end up with a very large matrix: more than 7 million elements.

Use the CreateMesh function instead. It is designed for exactly this.

2 replies

RichardJ19-TanzaniteAnswer
19-Tanzanite
May 24, 2013

The matrix function always starts at 0,0, so you get a divide by zero. You would also end up with a very large matrix: more than 7 million elements.

Use the CreateMesh function instead. It is designed for exactly this.

1-Visitor
May 28, 2013

Thanks Richard. That was very helpful and exactly what I was looking for. I am sure this has been answered on a previous post, but is there a way to reverse the scale on the vertical axis so that my data is visually correct when plotting data with increasing depth?

Regards,

T.S.

19-Tanzanite
May 28, 2013

In general, no, but in your case you can make the depths negative, from -1 to -BT.

25-Diamond I
May 24, 2013

Two other ways, but the second is by no means recommend.

1) Directly plot Deltasigma. In case of your function you can set the ranges for x and z so that the function will evaluate (I chose 0.0001 to 1959 for both)

2) create a new function Deltasigma2 which is ident with Deltasigma but will return 10^5 (or any other value) in case of an error using the onerror construct. You could use it with your approach but for reasons Richard already mentioned it would not be adviseable.