www.gusucode.com > mbcdemos 工具箱 matlab 源码程序 > mbcdemos/mbcConstraintsCmdLine.m
%% Using Constraints % This example shows how to create and apply constraints to a design using Model-Based Calibration % Toolbox(TM) command-line interface. % Copyright 2007-2014 The MathWorks, Inc. %% Create a Design % Create a Full Factorial design, because this will show the constraint % boundaries as clearly as possible. Create the design from inputs. For % simplicity, only 2 inputs (speed and load) are used. inputs = mbcmodel.modelinput(... 'Symbol', {'N','L'},... 'Name', {'SPEED','LOAD'},... 'Range', {[500 6000],[0.0679 0.9502]}); design = CreateDesign( inputs, 'Type', 'Full Factorial' ); design = Generate( design, 'NumberOfLevels', [50 50] ); % design has a Constraints property, initially this is empty. constraints = design.Constraints %% Create a Linear Constraint cLinear = CreateConstraint( design, 'Type', 'Linear' ); cLinear.A = [-2.5e-4, 1]; cLinear.b = 0.25; cLinear design.Constraints = cLinear; design = Generate(design); %% Show Constraint % Plot the points to show the linear constraint. Scatter2D(design, 1, 2); title( 'Linear Constraint' ); %% Create a 1D Table Constraint cTable1d = CreateConstraint( design, 'Type', '1D Table' ); cTable1d.Table = [0.9 0.5]; cTable1d.Breakpoints = [500 6000]; cTable1d design.Constraints = cTable1d; design = Generate(design); %% Show Constraint % Plot the points to show the 1D Table constraint. Scatter2D( design, 1, 2 ); title( '1D Table Constraint ' ); %% Combining Constraints % Constraints is an array of the constraints to apply. design.Constraints = [cLinear, cTable1d]; constraints = design.Constraints design = Generate(design); %% Show Constraint % Plot the points to show both constraints. Scatter2D( design, 1, 2 ); title( 'Linear and 1D Table Constraint ' ); displayEndOfDemoMessage(mfilename)