Turn on suggestions

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

Showing results for

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

Showing results for

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

10-17-2020
11:14 AM

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

10-17-2020
11:14 AM

'if' function on MathCAD

Hi everyone,

I did this project on Matlab so I'm not sure how it should be at MathCAD. I have 1 condition

Td(t) = if(t<theta,To,T*(t-theta).

My professor got the result from MathCAD, I'm not sure how do we use if function here?

I also attached the file in this post, the issue was occur at scenario 3.

Thank you so much again,

Solved! Go to Solution.

1 ACCEPTED SOLUTION

Accepted Solutions

10-19-2020
07:00 PM

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

10-19-2020
07:00 PM

You did not specify an initial condition for T.sf, so I used a random value (T.sf(0)=100°F).

Obviously you want it to change to T.sf(0)=120°F,

17 REPLIES 17

10-17-2020
12:23 PM

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

10-17-2020
12:23 PM

You only show scenario 1.

But the units for hc include capacitance instead of temperature:

Try

10-17-2020
12:27 PM

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

10-17-2020
12:27 PM

Hello

I fixed that already. I think I attached the wrong file.

Would you please help me to take a look again please?

Thank you so much

10-17-2020
12:36 PM

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

10-17-2020
12:36 PM

Your function T.d creates a unit mismatch and is incomplete.

For t=1 minute the result is a temperature but for t<1 minute the result is temperature times time and for t>1 minute there is no result defined:

BTW, what you wrote

Td(t) = if(t<theta,To,T*(t-theta)

could be done the very same way in Prime, too. Mathcad and also Prime offer two ways for an if. The if-statement in a program as you had used and the if-function (similar to the if function in a spreadsheet).

To duplicate in your program what the if-function does, you would have to use the "else" statement instead of the second "if". But the unit problem remains.

10-17-2020
12:57 PM

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

10-17-2020
12:57 PM

Hello,

Td = T(t)(t-theta). the T(t) was defined in the ODEs equation. so the purpose is finding T(t) using the first 3 ODEs, then plug T(t) to "if" function.

He said I could define Td like he did. But i'm not sure

10-17-2020
01:01 PM

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

10-17-2020
01:01 PM

T(t) returns a temperature, t and theta are time, so the result of T.d(t) would be temperature * time. Is this really what its supposed to be? I guess - no.

If the "original" was done with real Mathcad (version 15 or below), then it had to be done without units because odesolve-blocks did not work with units. Thats the reason you won't expirience the error in that version.

I am not sure if it makes sense, but you could get rid of the time by simply dividing by s

But you have a discontinuity at 1 min, which may be the reason for the odesolve-block after its definition to fail with some kind of strange error.

10-17-2020
01:11 PM

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

10-17-2020
01:11 PM

Hello,

I think I wrote it wrong. Td is the temperature of T(t) at time (t-1 min).

Example, Td = T at (time-1) which mean at t=0 min, T(t)=120, and at t=1, T(t) = 119. Td supposed to be the same as T at t=0 min and t=1 min

However, there is one minute delay so at t=1mins, Td = 120, which is the last value of T(t). and Td won't generate any reading at t=0

I hope this makes sense.

I wrote in matlab is for i=1:100, Td=T*(i-1), i is time range in minute.

Thank you so much!

10-17-2020
01:27 PM

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

10-17-2020
01:27 PM

You mean something like this:

I guess it would be better to replace "322.039 K" by "T(theta)".

According the solve block: You have an equation for a function T.sf there which you do not solve for. get rid of it and the solve block should work OK:

10-17-2020
01:32 PM

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

10-17-2020
01:32 PM

Hello,

that is what I did in scenario 2. now i need to solve for Tsf in scenario 3. Do you think if I specify in scenario T(t) will it be able to read the value from last run in scenario 2?

10-17-2020
01:39 PM

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

10-17-2020
01:39 PM

Whatever variable or function name you use, Prime will use the last definition of it.

But as you use T(t) as a function to solve for in your new solve block, Prime can't (and shouldn't) use last definition of it from the previous solve block.

10-17-2020
01:41 PM

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

10-17-2020
01:41 PM

I will remove the first 3 odes and will just define Td based on T(t) from last run. I hope it work

10-17-2020
03:11 PM

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

10-17-2020
03:11 PM

@TN_9676358 wrote:

I will remove the first 3 odes and will just define Td based on T(t) from last run. I hope it work

It does 😉

But the interval in the solve block for T must be a bit larger than the one for T.sf:

It has to do with the numerical derivatives the algorithm uses.

10-19-2020
06:57 PM

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

10-19-2020
06:57 PM

sorry i just read the message 😞 The graph I'm looking for looks differently. Im not sure what wrong. everything will need to start at T=120F. Do you have any ideas where am I wrong?

10-19-2020
07:00 PM

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

10-19-2020
07:00 PM

You did not specify an initial condition for T.sf, so I used a random value (T.sf(0)=100°F).

Obviously you want it to change to T.sf(0)=120°F,

10-19-2020
07:12 PM

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

10-19-2020
07:12 PM

Hello,

So Td and Tsf will start the first point at t=1, I specify the value of Tsf(0)=120F and they say the ODE range is larger. I believed for Td, because Td won't start until t=1, I think if t<0, there is no Td value.

Let me attached the new files for you.

I will need to specify both Tsf and Td starts at t=1 min.

Thank you so so much for your help

10-19-2020
07:21 PM

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

10-19-2020
07:26 PM

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

10-19-2020
09:27 PM

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

10-19-2020
09:27 PM

i got it. thank you so much.