%% Evaluate Smoothness Constraint on a Multidimensional Variable
% Create a requirement object to constrain the gradient magnitude of a 2-dimensional variable to be below 5.5.

Requirement = sdo.requirements.SmoothnessConstraint;

%

Requirement.GradientBound = 5.5;

%
% Specify 2-dimensional test data for the variable. In this example, generate test data with a gradient magnitude of 5, and use 2 as the spacing between the test data points in each dimension.

[X1,X2] = ndgrid(1:2:20,1:2:10);
variableData = 3*X1+4*X2;

% The gradient of the test data in the two dimensions is 3 and 4. Therefore, the gradient magnitude of the test data is 5 ( = \sqrt{3^2+4^2}).
%
% Specify the coordinates of the test data in each dimension.

indepVar1 = [1:2:20];
indepVar2 = [1:2:10];

% The specified coordinates indicate that the spacing between the test data points in both dimensions is 2.
%
% Evaluate if the test data satisfies the requirement.

Evaluation = evalRequirement(Requirement,variableData,indepVar1,indepVar2)

% Evaluation is a negative number, indicating that the requirement is satisfied, and the test data gradient magnitude is below the specified bound.
% Copyright 2012 The MathWorks, Inc.