MATLAB: How to make a multi-variable function

function

I want to turn f(x,y,z) = x^2 + 3y ^2 + 4z^2 – 2xy + 5x – 3y + 2z into an anonymous function

Best Answer

  • Do you mean like this?
    f = @(x,y,z) x.^2 + 3*y.^2 + 4*z.^2 - 2*x.*y + 5*x - 3*y + 2*z