cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Did you know you can set a signature that will be added to all your posts? Set it here! X

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

TeddySalvadore
1-Newbie

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

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.

1 ACCEPTED SOLUTION

Accepted Solutions

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.

View solution in original post

4 REPLIES 4

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.

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.

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

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.

Top Tags