Contenido principal

CustomTuning

R2026b

Custom tuning parameter

Since R2026b

    Description

    Add-On Required: This feature requires the Optical Design and Simulation Library for Image Processing Toolbox add-on.

    A CustomTuning object defines a custom tuning parameter that uses a custom function to modify an optical system during compensator optimization in sensitivity and tolerance analysis.

    Creation

    Description

    comp = optics.optimize.CustomTuning(fcnHandle,bound) creates a custom tuning parameter that uses the function specified by fcnHandle to modify the optical system, with optimization bounds defined by bound.

    comp = optics.optimize.CustomTuning(fcnHandle,bound,arg1,...,argN) passes the additional arguments arg1,...,argN to the custom tuning function.

    comp = optics.optimize.CustomTuning(___,Name=name) specifies a descriptive name for the custom tuning parameter.

    Note

    This functionality requires Optimization Toolbox™.

    example

    Input Arguments

    expand all

    Custom tuning function, specified as a function handle. The function must accept at least two input arguments: an opticalSystem object and a scalar tuning value. It must return exactly two output arguments: the modified opticalSystem object and the nominal scalar value.

    Data Types: function_handle

    Tuning bounds, specified as a 1-by-2 numeric vector of the form [min max] representing absolute bounds. Unlike built-in tuning parameters, custom tuning parameters do not support percentage bounds.

    Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

    Additional input arguments for the custom tuning function, specified as a comma-separated list. The types of the inputs depend on the function fcnHandle. These arguments are inputs to fcnHandle after the optical system and tuning parameter value arguments.

    Tuning parameter name, specified as a string scalar or character vector. Use this argument to identify the custom tuning parameter in the optimization set table.

    Data Types: char | string

    Properties

    expand all

    This property is read-only.

    Name of the tuned property, represented as a string scalar.

    This property is read-only.

    Custom tuning function, represented as a function handle.

    This property is read-only.

    Custom function arguments, represented as a cell array containing the additional arguments specified during object creation.

    Target index, specified as an empty array. Custom tuning parameters do not use target index resolution.

    Tuning bounds, specified as a 1-by-2 numeric vector of the form [lb ub] where lb and ub are the lower bound and upper bound, respectively.

    This property is read-only.

    Bound interpretation type, represented as "Absolute". Custom tuning parameters always use absolute bounds.

    Data Types: string

    Examples

    collapse all

    Import an optical system into the workspace.

    opsys = zmximport("CookeTriplet.zmx");

    Define a custom tuning parameter. The custom tuning function compensateAirGap is defined at the end of this example.

    comp = optics.optimize.CustomTuning(@compensateAirGap,[-0.5 0.5],2,Name="Air Gap")
    comp = 
      CustomTuning with properties:
    
        TargetProperty: "Air Gap"
        TuningFunction: @compensateAirGap
           TargetIndex: [1×0 double]
         CustomFcnArgs: {[2]}
                Bounds: [-0.5000 0.5000]
             BoundType: "Absolute"
    
    

    Custom Function

    The compensateAirGap custom function adjusts the air gap between components in an optical system. The function gets the current gap after a given component, and then increases or decreases it according to the tuning parameter value.

    function [opsys,nominalAirGap] = compensateAirGap(opsys,tuningValue,componentIndex)
        nominalAirGap = distanceAfter(opsys,componentIndex);
        changeGap(opsys,componentIndex,nominalAirGap+tuningValue);
    end

    Version History

    Introduced in R2026b