I have calculated a result matrix using the integrating function on matlab, however when I try to calculate the gradient of the result matrix, it says I have too many outputs.
My code is as follows:
x = linspace(-1,1,40);
y = linspace(-2,2,40);
for ii = 1:numel(x);
for jj = 1:numel(y)
fun = @(x) x(ii) + y(jj)
V(ii,jj) = integral(fun, 0, 2());
[qx,qy] = -gradient(V);
I tried to set up a meshgrid first to do my calculation over x and y, however the integral matlab function couldn't handle a meshgrid.
Any idea how I could calculate the gradient of my resulting V function?
Note that I have replaced my actual function with a more simple function. I could not calculate the integral of my function directly and thus am resorting to numerical integration.