You can use anonymous functions in MATLAB code intendedfor code generation. For example, you can generate code for the following MATLAB codethat defines an anonymous function that finds the square of a number.sqr = @(x) x.^2;a = sqr(5);
Anonymous functions are useful for creating a function handleto pass to a MATLAB function that evaluates an expression overa range of values. For example, this MATLAB code uses an anonymousfunction to create the input to the fzero function:b = 2;c = 3.5;x = fzero(@(x) x^3 + b*x + c,0);