Extract value from function
7 views (last 30 days)
Show older comments
Jose on 5 Sep 2022
Answered: Walter Roberson on 5 Sep 2022
Hello friends, I have this code that return values for dc1dt and dq1dt. But I want to see the values for dc1dz, how can I do that?
Walter Roberson on 5 Sep 2022
Chances are that you do not want to see that.
You are obviously calling an ode*() function. Your function f is going to be evaluated at a series of trial points "near" the current location, in order to predict what the new location should be, and then a cross-check is done to see if the value at another location is "close enough" to a value that the proposed coefficients would predict. For ode45() this involves calculating the function 6 times at each location, with none of the computed locations necessarily making it into the output. If the cross-check was too far away from prediction, then the ode*() goes back and tries again with a smaller step size, another 6 calculations. For any system that cannot be described by a quintic or lower degree polynomial, it is normal for a number of points to be rejected.
Knowing the dc1dz values for a number of trial locations that were never going to make it to output is seldom of benefit.
None of the locations evaluated at necessarily make it to output: the output can end up consisting entirely of predicted values.
For these reasons, most of the time it is much better to call ode45() or whatever normally, getting outputs for various time steps, and then go back and compute the dc1dz values that would be associated with those boundary conditions.
You can use the same function with dc1dz as the second output; loop over the rows of boundary conditions calling the function and capturing the second output... and do whatever with it.
More Answers (0)
Find more on General PDEs in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!