MATLAB differentiation when the derivative of a function is numerically known


I want to differentiate the following function wrt in MATLAB: T(<sup>e(x(t),t)</sup>⁄<sub>p(t)</sub>)

My problem is that I know the derivatives of x numerically (I am inside a kind of odefun). I want to use diff to make my code generalizeable for high order derivatives,but the derivatives of x are now constant. I would also like all this to be in an anonymous function where I can make the differentiation and substitute accordingly the time and the derivative of x needed,so that I don't have to write multiple functions for every state of my system.

My code is as follows:

syms q x star; qd=symfun(90*pi/180+30*pi/180*cos(q),[q]); p=symfun(79*pi/180*exp(-1.25*q)+pi/180,[q]); T=log(-(1+star)/star); e=symfun(x-qd,[x,q]);

and I want to write for example a function in the form

@(t,y)(<sup>d^2</sup>⁄<sub>dt^2</sub> T(<sup>e(x(t),t)</sup>⁄<sub>p(t)</sub>)+<sup>d</sup>⁄<sub>dt</sub> T(<sup>e(x(t),t)</sup>⁄<sub>p(t)</sub>)+T(<sup>e(x(t),t)</sup>⁄<sub>p(t)</sub>))


I am not sure of the implementation details but in general this is one approach that you could take. It involves two steps.

<ol><li>in the T(.) function replace x with exp(t) this way when you do the differentiation exp(t) always stays there for the higher order derivatives to be taken and the outer functions will be differentiated with respect to x at the same time. After you do diff you should receive an expression that contains exp(t) (not tested so hopefully it is the case). At this point exp(t) is your time derivative of x. Now you only need to evaluate this expression in t. When doing so you need to replace exp(t) by the derivative of x. I do not know if this can be done, if not then perhaps using y instead of exp(t) with the constraint y=exp(t) would do it but you need to figure the correct implementation out yourself. </li> <li>Here you need to substitute the derivative of x at the right t. If you do not have the value at the particular point t then do what I suggested in the comment. Pre-calculate it beforehand in many points and interpolate in this step. </li> </ol>

This approach relies on swapping x(t) with exp(t) if that does not work then I would do what I suggested in the comment. Approximate x(t) by a known function and use that instead of x in your code.


  • Q-learning in neural network not 'learning'
  • Why multiply the error by the derivative of the sigmoid in neural networks?
  • List all files in a folder and subfolders in Excel
  • Geometry shader doesn't do anything when fed GL_POINTS
  • Getting Coordinates of a Point in a circle
  • Using sed to extract string values
  • How to apply a partial derivative Gaussian kernel to an image with OpenCV?
  • Suspending event listeners
  • Python sin and cosine giving incorrect values
  • Subclassing a Pandas DataFrame, updates?
  • How can I use a custom function within an expression using the eval dataframe method?
  • How Get arguments value using inline assembly in C without Glibc?
  • How to make R's read_csv2() recognise the text characters properly
  • Reading a file into a multidimensional array
  • Object and struct member access and address offset calculation
  • Implementation of State Monad
  • Hardware Accelerated Image Scaling in windows using C++
  • Magento Fatal error: Maximum execution error solution, on WAMP
  • How do I pass the string value parameter of the selected list item from an auto-populated dropdown l
  • Repeat a vertical line on every page in Report Builder / SSRS
  • Email format validation in mvc3 view
  • Android screen density dpi vs ppi
  • C# - Is there a limit to the size of an httpWebRequest stream?
  • Bug in WPF DataGrid
  • How to add date and time under each post in guestbook in google app engine
  • How to recover from a Spring Social ExpiredAuthorizationException
  • output of program is not same as passed argument
  • Does CUDA 5 support STL or THRUST inside the device code?
  • Statically linking a C++ library to a C# process using CLI or any other way
  • Timeout for blocking function call, i.e., how to stop waiting for user input after X seconds?
  • Why winpcap requires both .lib and .dll to run?
  • A cron job substitute?
  • Windows forms listbox.selecteditem displaying “System.Data.DataRowView” instead of actual value
  • Proper folder structure for lots of source files
  • coudnt use logback because of log4j
  • Can Visual Studio XAML designer handle font family names with spaces as a resource?
  • How does Linux kernel interrupt the application?
  • How can I remove ASP.NET Designer.cs files?
  • Are Kotlin's Float, Int etc optimised to built-in types in the JVM? [duplicate]
  • java string with new operator and a literal