MATLAB: Feval only for a certain variables

functionMATLABmatlab functionsymbolic

I computed a symbolic formula, for example fun=x^2*z^2+y^2*w^2 (in my case I have many symbolic variables) , after this I convert the symbolic formula in function handle (with "matlabFunction"), for example fun=@(x,z,y,w) x^2*z^2+y^2*w^2. I need to substitute in this function only certain variables, for example only z and w, and after other calculations substitute the other variables. Can I do this with "feval" or exist other functions?

Best Answer

You can pass symbolic variables to anonymous functions.
fun=@(x,z,y,w) x^2*z^2+y^2*w^2;
syms x y
newexpression = fun(x, 5, y, 6);
You can matlabFunction the result if appropriate.
Related Question