 and
 and  . so you cannot use dydx again in dlgradient. also for second derivative you have 4 elements :
 . so you cannot use dydx again in dlgradient. also for second derivative you have 4 elements :  ,
 ,  ,
 ,  ,
 , 
 and
 and  . so you cannot use dydx again in dlgradient. also for second derivative you have 4 elements :
 . so you cannot use dydx again in dlgradient. also for second derivative you have 4 elements :  ,
 ,  ,
 ,  ,
 , 
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!