Hauptinhalt

opticalTolerance

R2026b

Monte Carlo tolerance analysis of optical system

Since R2026b

    Description

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

    result = opticalTolerance(opsys,meritFcn,tolSet) performs Monte Carlo tolerance analysis on the optical system opsys by applying random perturbations to the specified tolerances tolSet for each trial and evaluating the merit function meritFcn. The function returns the per-trial metric scores.

    result = opticalTolerance(opsys,meritFcn,tolSet,Name=Value) specifies additional options using one or more name-value arguments. For example, NumTrials=1000 increases the number of Monte Carlo samples to 1000.

    example

    Examples

    collapse all

    Import an optical system into the workspace.

    opsys = zmximport("DoubleGaussLens.zmx");

    Create an optical tolerance set with a tolerance for the radius of curvature of surfaces.

    tolSet = opticalToleranceSet;
    tolSet = addSurfaceConicConstantTolerance(tolSet,0.07);

    Create a merit function object for evaluating system performance.

    meritFcn = opticalMeritFunction;
    meritFcn = addSpot(meritFcn);

    Run a Monte Carlo tolerance analysis with 100 trials on the optical system using the merit function, and tolerance.

    resultTolerance = opticalTolerance(opsys,meritFcn,tolSet,NumTrials=100);

    Perturb the optical system using the results from the 12th Monte Carlo trial.

    idx = 12;
    newopsys = applyPerturbation(resultTolerance,idx,CompensatorApplied=false);

    Evaluate the merit function of the perturbed optical system, and observe that the metric score and the raw metric value match the merit score and raw metric value in the results.

    [score,rawValue] = evaluate(meritFcn,newopsys)
    score = 
    0.0557
    
    rawValue = 
    0.0557
    
    resultTolerance.MeritScore(idx)
    ans = 
    0.0557
    
    resultTolerance.ResultTable.Metric(idx)
    ans = 
    0.0557
    

    Input Arguments

    collapse all

    Optical system to analyze, specified as an opticalSystem object.

    Merit function, specified as an opticalMeritFunction object containing the metrics to evaluate. Monte Carlo analysis predicts manufacturing performance distributions and yield, so you can include multiple metrics simultaneously to check multiple specifications.

    Tolerance set, specified as an opticalToleranceSet object containing the parameters to perturb and their tolerance values.

    Name-Value Arguments

    collapse all

    Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

    Example: opticalTolerance(opsys,meritFcn,tolSet,NumTrials=500) specifies 500 Monte Carlo trials.

    Number of Monte Carlo trials, specified as a positive integer. Each trial applies a random perturbation sampled from a uniform distribution within the tolerance range for each parameter in the tolerance set.

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

    Compensator optimization set, specified as an opticalOptimizationSet object containing the tuning parameters to optimize after each perturbation. Use this argument to obtain realistic post-adjustment performance predictions, such as when an autofocus mechanism compensates for manufacturing errors. To specify a compensator, you must have an Optimization Toolbox™ license.

    Parallel computing, specified as a logical 1(true) or 0(false). Specify UseParallel as true to distribute Monte Carlo trials across parallel workers. This option requires Parallel Computing Toolbox™.

    Data Types: logical

    Output Arguments

    collapse all

    Tolerance analysis results, returned as an OpticalTolerance object that contains a table with one row per Monte Carlo trial, including pre- and post-compensation metric scores.

    Version History

    Introduced in R2026b