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

Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X

6-Contributor

## Odesolve solve block Variable still showing Undefined

Am I missing something in the solve block? I tried not to extend the equations too much, for instance, Instead of typing out the full equation for h_tga, I define h_tga above then call for h_tga in equations 1,2 &3. Would I be better off typing all the variables **bleep** for tat?

3 REPLIES 3
24-Ruby V
(To:ML_9447606)

At first glace I see two problems:

1) You use function but omit the argument! That way its interpreted as variable! You have to write P.w(t), T.w(t), etc.

2) If you use that kind of "abbrevations" using auxiliary functions like P.w(t) which are dependent on the searched for functions like T.w(t), you must also let odesolve solve for these functions, too (and provide initial conditions).

So it may be better, not to use those aux functions.

A way to get around this problem and nonetheless use those aux functions could be this:

Define your functions above the solve block like this:

and use this function in the solveblock that way:

6-Contributor
(To:Werner_E)

Using the workaround that you suggested, would I have it setup like the following then?

24-Ruby V
(To:ML_9447606)

When you click on the region with the error and go to the calculation ribbon menu, you have the option here to trace the error. If you do so, you are sent to this region:

There are a couple of problems:

1) You forgot to write Tw(t) instead of just Tw a couple of times

2) You would also have to define h.cwg to be a function of t, not just a variable

3) You can't define h.cwg(t) using T.w(t), because T.w(t) is not yet defined (you are just looking for it).

You could use the boolean = instead of the assignment, but if you do so, you would also include h.cwg in the least of functions you would like to find with odesolve.

A better approach IMHO is this:

As with P.w and P.g you define in front of the solve block

and use it in the solve block like

This may apply to other functions as well.

NOTE: Everything you define with an assignment operator ":=" should be placed outside and in (if necessary) in front of the solve block. And if it depends on the functions you are just looking for, you have to do it similar to what I just showed with h.cwg.

Announcements