Coding and Minimizing an Objective Function Using Pattern Search - MATLAB & Simulink - MathWorks India Skip to content Toggle Main Navigation Products Solutions Academia Support Community Events Get MATLAB Products Solutions Academia Support Community Events Get MATLAB Help CenterHelp Center Search Help Center Help Center MathWorks Search MathWorks.com MathWorks Support Close Mobile Search Open Mobile Search Off-Canvas Navigation Menu Toggle Documentation Home Mathematics and Optimization Global Optimization Toolbox Direct Search Coding and Minimizing an Objective Function Using Pattern Search On this page Objective Function Code the Objective Function Minimize Using patternsearch Minimize Using Additional Arguments Vectorize the Objective Function References Related Topics Documentation Examples Functions Videos Answers Trial Software Trial Software Product Updates Product Updates Resources Documentation Examples Functions Videos Answers Main Content Coding and Minimizing an Objective Function Using Pattern Search Open Live Script This example shows how to create and minimize an objective function using pattern search. Objective Function For this problem, the objective function to minimize is a simple function of a 2-D variable x. simple_objective(x) = (4 - 2.1*x(1)^2 + x(1)^4/3)*x(1)^2 + x(1)*x(2) + (-4 + 4*x(2)^2)*x(2)^2; This function is known as "cam," as described in L.C.W. Dixon and G.P. Szego [1]. Code the Objective Function Create a MATLAB® file named simple_objective.m containing the following code: type simple_objective function y = simple_objective(x) %SIMPLE_OBJECTIVE Objective function for PATTERNSEARCH solver