主要内容

opticalMeritFunction

R2026b

Optical merit function

Since R2026b

    Description

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

    An opticalMeritFunction object combines optical performance metrics into a single weighted scalar score for use in optimization and tolerance analysis.

    Creation

    Description

    meritFcn = opticalMeritFunction creates an empty merit function with no metrics. Add metrics using the object functions.

    example

    Properties

    expand all

    Metric objects, specified as a 1-by-n array of Metric objects.

    Metric weights, specified as a 1-by-n positive numeric vector. The object normalizes weights to sum up to 1 when computing the combined merit score. The combined merit score is the mean of the absolute residual scores weighted by the square roots of the weights.

    This property is read-only.

    Summary table of metrics, represented as a table with these columns: Name, Target, and Weight. The columns correspond to the properties of the metric objects added to the merit function, with each row representing those properties for a single metric object.

    Object Functions

    addSpotAdd spot RMS metric to merit function
    addWavefrontPeakToValleyAdd peak‑to‑valley wavefront error metric to merit function
    addWavefrontRMSAdd RMS wavefront error metric to merit function
    addCustomMetricAdd custom metric to merit function
    evaluateEvaluate merit function

    Examples

    collapse all

    Import an optical system into the workspace.

    opsys = zmximport("PhotographicLens.zmx");

    Create an empty optical merit function.

    meritFcn = opticalMeritFunction;

    Add a spot RMS metric to the merit function.

    meritFcn = addSpot(meritFcn);

    Add a peak‑to‑valley wavefront error metric to the merit function.

    meritFcn = addWavefrontPeakToValley(meritFcn);

    Add an RMS wavefront error metric with a target RMS wavefront range of 0 to 0.2 waves to the merit function.

    meritFcn = addWavefrontRMS(meritFcn,Target=[0 0.1]);

    Specify weights for the metrics in the merit function.

    meritFcn.Weights = [3 7 5];

    Inspect the merit function.

    meritFcn
    meritFcn = 
      opticalMeritFunction with properties:
    
             Metrics: [1×3 optics.metric.Metric]
             Weights: [3 7 5]
        MetricsTable: [3×3 table]
    
    
    meritFcn.Metrics
    ans = 1×3 heterogeneous Metric (SpotRMS, WavefrontPeakToValley, WavefrontRMS) array with properties:
        Name
        Target
    
    
    meritFcn.Weights
    ans = 1×3
    
         3     7     5
    
    
    meritFcn.MetricsTable
    ans = 3×3 table
                        Name                Target     Weight
             __________________________    ________    ______
    
        1    "Spot"                        0      0      3   
        2    "Wavefront Peak To Valley"    0      0      7   
        3    "Wavefront RMS"               0    0.1      5   
    
    

    Evaluate the merit function for the optical system.

    [score,rawMetricValues] = evaluate(meritFcn,opsys)
    score = 
    0.6514
    
    rawMetricValues = 1×3
    
        0.0076    0.7206    0.1410
    
    

    Version History

    Introduced in R2026b