Hi, i have a symbolic function of 3 variables and then I compute its gradient and convert each entry of the gradient to a function handle,but some of them become function handles of less than 3 variables, and that makes the evaluation of the vector field more difficult, any ideas on how to solve this?
syms x y z f=x*y*z+x*2*yG=gradient(f)Dx=matlabFunction(G(1));Dy=matlabFunction(G(2));Dz=matlabFunction(G(3));[X,Y,Z]=meshgrid(-3:1:3);Fx=Dx(Y,Z);Fy=Dy(X,Z);Fz=Dz(X,Y);
this code works but i would like it to work when i write:
Fx=Dx( X,Y,Z);Fy=Dy(X,Y,Z);Fz=Dz(X,Y,Z);
and this is what my function handles look like:
Dx =@(y, z) y .* z + 2 .* yDy =@(x, z) x .* z + 2 .* xDz =@(x, y) x .* y
Best Answer