Replace
with
temp = arrayfun(@(X, Y) odehandle([],[X,Y]), x, y, 'uniform', 0);
dx = cellfun(@(C) C(1), temp);
dy = cellfun(@(C) C(2), temp);
This is for the special case that the ODE is a function of two variables and the first derivatives apear as the first two elements of the output vector.
The 3D equivalent would be something like,
function plot_vectorfield(odehandle)
[x, y, z]=meshgrid(-10:1:10, -10:1:10, -10:1:10);
temp = arrayfun(@(X, Y, Z) odehandle([],[X,Y,Z]), x, y, z, 'uniform', 0);
dx = cellfun(@(C) C(1), temp);
dy = cellfun(@(C) C(2), temp);
dz = cellfun(@(C) C(3), temp);
quiver3(x, y, z, dx, dy, dz);
end
Best Answer