I'm using Adigator to create the derivative file of an objective function that uses a form of nimerical integration (trapz for instance). Howver, this is the error I receive:
*Error using trapz (line 53)
X must be a vector.
*Error in adigatortempfunc1 (line 12)*
*output=trapz(y);
*Error in adigator (line 510)
FunctionInfo = adigatortempfunc1(FunctionInfo,UserFunInputs);*
*Error in Main (line 37)
Outputs = adigator('Objfun',{d,gX,u},'Objfunxder',adigatorOptions('overwrite',1))**
I used the following code to create the derivative file:
ADiGator works based off of operator overloading and can thus only differentiate matlab functions that have been overloaded (or whose source code it can read). The issue is that I never overloaded trapz().
A workaround is to just write out the math for trapz. This, however, will not work with vectorization as it violates the vectorization assumption that dF(X(i))/dX(j) = 0 forall i~=j. That is, your code sums over the vectorized dimension.
So, in your case you would need to fix the vectorized dimension, and then trapz would need to be written out something like:
Hi,
I'm using Adigator to create the derivative file of an objective function that uses a form of nimerical integration (trapz for instance). Howver, this is the error I receive:
I used the following code to create the derivative file:
The objective function is very simple and I'm using it to get a sense of how adigator works.:
How can I fix this? I appreciate your help.
Last edit: Saeed Azad 2018-03-13
Hi Saeed,
ADiGator works based off of operator overloading and can thus only differentiate matlab functions that have been overloaded (or whose source code it can read). The issue is that I never overloaded trapz().
A workaround is to just write out the math for trapz. This, however, will not work with vectorization as it violates the vectorization assumption that dF(X(i))/dX(j) = 0 forall i~=j. That is, your code sums over the vectorized dimension.
So, in your case you would need to fix the vectorized dimension, and then trapz would need to be written out something like:
Hope that helps!
Matt W.