Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X
I am unable to get the evaluation of Derivative in attached worksheet. How do I get it evaluated?
Hi,
Need to define a value for Rho typically density so I chose air at 1.25kg/m^3.
Cheers
Terry
Your sheet does not work - maybe due to an error in the protected area. First error message is that rho is not defined.
But the problem is clear anyway: A solve block with odesolve returns a numerical solution, not a symbolic one. You don't get a symbolic function definition and so you can't demand a symbolic derivative.
All you can do is to numerically evaluate the functions at positions within the interval from 0 to 20 s and you may also numerically evaluate their derivatives as you already did in the plot. So Phi(2s)= will work, but Phi(t)= or Phi(t)-> can't - apart from the fact that you already defined t as a range!
Starting with version 9 PTC implemented a way to symbolically solve some simple ODEs and systems of ODEs See Solving ODEs Symbolically
If you are in need for a symbolic solution you may give that a try.
EDIT: In case that your intention was to just make some sort of table of values, you should not use a range but rather a vector of t-values and call the function vectorized.
The derivatives may fail at the end postions (0s and 20s) because the numeric algorithm needs neigbour-points which do not exist at the ends of the interval. Nonetheless you may filter the failing values and still see the other values or you define a vector of t-values which does not include the problematic end values.
For more help and showing what I mean we would need a working sheet of course.
As Terry kindly provided a working sheet by adding an appropriate value for rho, here some additional remarks:
The calculation of the derivatives fails because of the end values (0s, 20s) as already explained
You may fix this by using try & catch
It may be worth to define a small utility function to do that job
!! !BUT ,,,
You can't assign these values to a variable for later use as its NOT a vector! So of course vectorization does not help at all
Despite of the misleading error message the true reason is (as written in my previous answer) that t is a range, not a vector!.
There is an undocumented trick to turn a range into a vector by following the assignment with an inline evaluation:
t_vec is now a legitimate vector, not a range (unfortunately ranges and vectors look the very same in Prime).
A more "legal" way to create that very same vector is seen here:
Now you can use this vector to create a table for later use - don't forget about vectorization (the arrow over the expression)
or create a more comprehensive table
But of course you still can't evaluate the functions and their derivatives symbolically as you tried to do because the functions derived by OdeSolve are numeric only.