Get Help

Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Community
- :
- PTC Mathcad
- :
- PTC Mathcad
- :
- Error creating matrix of 2 variable function - sub...

Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

05-24-2013
10:41 AM

05-24-2013
10:41 AM

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.

Solved! Go to Solution.

1 ACCEPTED SOLUTION

Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

05-24-2013
11:15 AM

05-24-2013
11:15 AM

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.

4 REPLIES 4

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

05-24-2013
11:15 AM

05-24-2013
11:15 AM

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.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

05-24-2013
11:49 AM

05-24-2013
11:49 AM

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

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.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

05-28-2013
07:44 PM

05-28-2013
07:44 PM

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

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.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

05-28-2013
07:54 PM

05-28-2013
07:54 PM

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

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

Top Tags