I defined a matrix of variables like this
X=[X1 X2 X3 X4]'
Then the code did some stuff on X to give a vector d of the form
Now I need to differentiat the ith element of d wrt the ith element of X, in other words I want to do this
I tried this
E=gradient(d, [X(1) X(2) X(3) X(4)]);
It gave me an error "The first argument must be a scalar"
So what should I do now?