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
- :
- Create a function for line graph values?

Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- 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
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

09-17-2018
10:30 AM

09-17-2018
10:30 AM

In the attached Mathcad prime 3.1 worksheet (along with screenshot) I've graphed two vectors in an X-Y plot. Is it possible to create a function such that the user can type in any value for temperature( within the highest and lowest value) and receive the temperature back?

Solved! Go to Solution.

Labels:

1 ACCEPTED SOLUTION

Accepted Solutions

Highlighted

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

09-17-2018
10:49 AM

09-17-2018
10:49 AM

Yes, that function is

GetTemp(Temp):=Temp

You call the function with, e.g.

GetTemp(15)=

and it results in

GetTemp(15)=15.

That's what you asked, but not what you meant to ask....

I'm afraid you want a function where you give an Ec value, and get the correcponding temperature. That is partially possible.

I think the answer to your question lies with the function linterp(), look it up in the help, and see how it works.

The problem is that there is a temperature ** range** where the Ec value is 1. What temperature would you expect to get for Ec=1?

Success!

Luc

6 REPLIES 6

Highlighted

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

09-17-2018
10:49 AM

09-17-2018
10:49 AM

Yes, that function is

GetTemp(Temp):=Temp

You call the function with, e.g.

GetTemp(15)=

and it results in

GetTemp(15)=15.

That's what you asked, but not what you meant to ask....

I'm afraid you want a function where you give an Ec value, and get the correcponding temperature. That is partially possible.

I think the answer to your question lies with the function linterp(), look it up in the help, and see how it works.

The problem is that there is a temperature ** range** where the Ec value is 1. What temperature would you expect to get for Ec=1?

Success!

Luc

Highlighted
##

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

09-17-2018
11:58 AM

09-17-2018
11:58 AM

Re: Create a function for line graph values?

Here's an example using linterp().

Note that it works because there is a one-to-one relation between Temp and Ec values. If that is not the case (as in your example where Ec=1 on a range of Temp values), the linterp() funtion will complain. In that case using spline functions (see the answer below) may (...) help.

Success!

Luc

Highlighted
##

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

09-17-2018
10:59 AM

09-17-2018
10:59 AM

Re: Create a function for line graph values?

Mathcad provides a variety of methods for fitting functions to data.

Attached worksheet fits cubic spline to your data.

Highlighted
##

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

09-17-2018
12:01 PM

09-17-2018
12:01 PM

Re: Create a function for line graph values?

Thank you rgunwaldsen. What format (or version) is your worksheet; I'm unable to open it.

Highlighted
##

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

09-17-2018
12:26 PM

09-17-2018
12:26 PM

Re: Create a function for line graph values?

I used Prime 5. PTC has made it impossible to copy/paste stuff into prior versions of Prime.

Attached is "xps" printout.

The functions used are straight out of the help example for "Example: Cubic Spline Interpolation

Example: Cubic Spline Interpolation".

Advantage for cubic spline fit for interpolation within range is that it provides "smooth" function with continuity of function and 1st/2nd derivatives.

Roger

Highlighted
##

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

09-17-2018
11:57 AM

09-17-2018
11:57 AM

Re: Create a function for line graph values?

My guess is that you want a function to calculate Ec from a given temp and not the other way round.

If linear interpolation is sufficient you may do like this: