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

Community Tip - If community subscription notifications are filling up your inbox you can set up a daily digest and get all your notifications in a single email. X

6-Contributor

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,

1 ACCEPTED SOLUTION

Accepted Solutions
24-Ruby V
(To:TN_9676358)

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
23-Emerald I
(To:TN_9676358)

You only show scenario 1.

But  the units for hc include capacitance instead of temperature:

Try

6-Contributor
(To:Fred_Kohlhepp)

Hello

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

Thank you so much

24-Ruby V
(To:TN_9676358)

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.

6-Contributor
(To:Werner_E)

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

24-Ruby V
(To:TN_9676358)

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.

6-Contributor
(To:Werner_E)

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!

24-Ruby V
(To:TN_9676358)

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:

6-Contributor
(To:Werner_E)
Spoiler

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?

24-Ruby V
(To:TN_9676358)

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.

6-Contributor
(To:Werner_E)

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

24-Ruby V
(To:TN_9676358)

@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.

6-Contributor
(To:Werner_E)

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?

24-Ruby V
(To:TN_9676358)

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,

6-Contributor
(To:Werner_E)

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

6-Contributor
(To:TN_9676358)

and the graph supposed to look like this.

Thank you so much.

6-Contributor
(To:TN_9676358)
Spoiler
Spoiler

oh no I didn't get Tsf :(, I just got Td(t) :((

6-Contributor
(To:TN_9676358)

i got it. thank you so much.

Announcements
Top Tags