メインコンテンツ

opticalCoatingEditor

Optical coating editor UI component

Since R2026a

    Description

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

    An optical coating editor UI component enables an app user to interactively edit the layers of an optical coating and tune its performance parameters, such as transmission, reflection, and absorption power coefficients. For more information about the interactions that the optical coating editor UI component enables, see Optical Coating Editor Interactions. Properties of the OpticalCoatingEditor object control the appearance and behavior of the UI component.

    Creation

    You can create a OpticalCoatingEditor object using the opticalCoatingEditor function described below.

    Description

    coatingEditor = opticalCoatingEditor creates an optical coating editor in a new figure. The UI component enables you to edit and visualize the layer structure and optical performance of optical coatings from the coating library and MATLAB® workspace. You can integrate the editor in your own custom apps.

    coatingEditor = opticalCoatingEditor(PropertyName=Value) specifies OpticalCoatingEditor sets writable properties of the optical coating editor UI component using one or more optional name-value arguments. For example, opticalCoatingEditor(Coating=SiO2Coat) opens the optical coating SiO2Coat in the optical coating editor and visualizes the coating properties and performance.

    example

    Output Arguments

    expand all

    Optical coating editor UI component, returned as an OpticalCoatingEditor object.

    Properties

    expand all

    Coating Settings

    Coating to edit in the optical coating editor, specified as an opticalCoating object.

    Number of sampled wavelengths in the spectral response plots, specified as a positive integer.

    Number of sampled incident angles in the spectral response plots, specified as a positive integer. Increase the NumAngleSamples value to improve transmittance, reflection, and absorbance plot smoothness at the expense of higher computation time and memory usage.

    Incident light direction with respect to the coating, specified as one of these options:

    • "medium2substrate" — Incoming incident light rays travel from the direction of the medium through the substrate.

    • "substrate2medium" — Incoming incident light rays travel from the direction of the substrate through the medium.

    Editor Settings

    Editable state of coating editor, represented as "on" or "off", or as numeric or logical 1 (true) or 0 (false). A value of "on" is equivalent to true, and "off" is equivalent to false. You can use the value of this property as a logical value. The value is stored as an on/off logical value of type matlab.lang.OnOffSwitchState.

    • "on" — The optical coating editor displays controls for setting the name, wavelength range, incident angle range, layer materials, and layers of the optical coating.

    • "off" — The optical coating editor hides all controls except the Flip Light button and Heatmap for parameter."

    Position

    UI component size and location excluding the margins, specified as a 4-element vector of the form [left bottom width height]. The values of left and bottom specify the location of the lower-left corner of the UI component, and width and height specify its dimensions in the x- and y-directions, respectively. By default, MATLAB measures the values in units normalized to the container. To change the units, set the Units property.

    This property is read-only.

    Inner size and location, represented as a 4-element vector of the form [left bottom width height]. This property is equivalent to the Position property.

    Size and location including the labels and margin, specified as a 4-element vector of the form [left bottom width height]. The values of left and bottom specify the location of the lower-left corner of the UI component, and width and height specify its dimensions in the x- and y-directions, respectively. By default, MATLAB measures the values in units normalized to the container. To change the units, set the Units property.

    Units of measurement, specified as one of these options.

    Units ValueDescription
    "normalized" (default)Normalized with respect to the container, which is typically a figure or panel. The lower-left corner of the container maps to (0, 0) and the upper-right corner maps to (1, 1).
    "inches"Inches.
    "centimeters"Centimeters.
    "characters"

    Based on the default uicontrol font of the graphics root object.

    • Character width = width of the letter x.

    • Character height = distance between the baselines of two lines of text.

    "points"Typography points. One point equals 1/72 inch.
    "pixels"

    Pixels.

    On Windows® and Macintosh systems, the size of a pixel is 1/96 inch. This size is independent of your system resolution.

    On Linux® systems, the size of a pixel is determined by your system resolution.

    Layout options, specified as a GridLayoutOptions object. This property specifies options for components that are children of grid layout containers. If the component is not a child of a grid layout container (for example, it is a child of a figure or panel), then this property is empty and has no effect. However, if the component is a child of a grid layout container, you can place the component in the intended row and column of the grid by setting the Row and Column properties of the GridLayoutOptions object.

    For example, this code places an optical coating editor in the third row and second column of its parent grid.

    g = uigridlayout([4 3]);
    editor = opticalCoatingEditor(Parent=g);
    editor.Layout.Row = 3;
    editor.Layout.Column = 2;

    Interactivity

    State of visibility, specified as "on" or "off", or as numeric or logical 1 (true) or 0 (false). A value of "on" is equivalent to true, and "off" is equivalent to false. Thus, you can use the value of this property as a logical value. The value is stored as an on/off logical value of type matlab.lang.OnOffSwitchState.

    • "on" — Display the object.

    • "off" — Hide the object without deleting it. You can still access the properties of an invisible UI component.

    To make your app start faster, set the Visible property to "off" for all components that do not need to appear at startup.

    Changing the size of an invisible container triggers the SizeChangedFcn callback when it becomes visible.

    Changing the Visible property of a container does not change the values of the Visible properties of child components. This is true even though hiding the container causes the child components to be hidden.

    Context menu, specified as a ContextMenu object created using the uicontextmenu function. Use this property to display a context menu when you right-click on an area of the component that does not contain any underlying UI components or graphics objects.

    To display a context menu when you right-click on any portion of the custom UI component, write code to set the ContextMenu property of all underlying UI components and graphics objects whenever the ContextMenu property of your custom component is set.

    Color and Styling

    Background color, specified as an RGB triplet, a hexadecimal color code, or one of the color options listed in the table.

    Color NameShort NameRGB TripletHexadecimal Color CodeAppearance
    "red""r"[1 0 0]"#FF0000"

    Sample of the color red

    "green""g"[0 1 0]"#00FF00"

    Sample of the color green

    "blue""b"[0 0 1]"#0000FF"

    Sample of the color blue

    "cyan" "c"[0 1 1]"#00FFFF"

    Sample of the color cyan

    "magenta""m"[1 0 1]"#FF00FF"

    Sample of the color magenta

    "yellow""y"[1 1 0]"#FFFF00"

    Sample of the color yellow

    "black""k"[0 0 0]"#000000"

    Sample of the color black

    "white""w"[1 1 1]"#FFFFFF"

    Sample of the color white

    Callbacks

    Coating change callback, specified as one of these values:

    • Function handle.

    • Cell array in which the first element is a function handle. Subsequent elements in the cell array are the arguments to pass to the callback function.

    • Character vector containing a valid MATLAB expression (not recommended). MATLAB evaluates this expression in the base workspace.

    For more information about specifying a callback as a function handle, cell array, or character vector, see Callbacks in App Designer.

    The CoatingChangedFcn callback executes when the user selects a new coating using the optical coating editor UI component.

    This callback function can access your selected coating as you interact with the optical coating editor. MATLAB passes this information in a CoatingChanged event as the second argument in the callback function. In App Designer, the argument is named event. You can get the object properties using dot notation. For example, event.PreviousValue gets the previously selected coating.

    The CoatingChangedFcn callback does not execute when the user reselects the currently selected coating. The callback also does not execute when you change the Coating property programmatically.

    Size change callback, specified as one of these values:

    • Function handle.

    • Cell array in which the first element is a function handle. Subsequent elements in the cell array are the arguments to pass to the callback function.

    • Character vector containing a valid MATLAB expression (not recommended). MATLAB evaluates this expression in the base workspace.

    For more information about specifying a callback as a function handle, cell array, or character vector, see Callbacks in App Designer.

    The SizeChangedFcn callback executes when:

    • The component becomes visible for the first time.

    • The component is visible while its size changes.

    • This component becomes visible for the first time after its size changes. This situation occurs when the size changes while the component is invisible, and then it becomes visible later.

    Object creation function, specified as one of these values:

    • Function handle.

    • Cell array in which the first element is a function handle. Subsequent elements in the cell array are the arguments to pass to the callback function.

    • Character vector containing a valid MATLAB expression (not recommended). MATLAB evaluates this expression in the base workspace.

    For more information about specifying a callback as a function handle, cell array, or character vector, see Callbacks in App Designer.

    This property specifies a callback function to execute when MATLAB creates the object. MATLAB initializes all property values before executing the CreateFcn callback. If you do not specify the CreateFcn property, then MATLAB executes a default creation function.

    Setting the CreateFcn property on an existing component has no effect.

    If you specify this property as a function handle or cell array, you can access the object that is being created using the first argument of the callback function. Otherwise, use the gcbo function to access the object.

    Object deletion function, specified as one of these values:

    • Function handle.

    • Cell array in which the first element is a function handle. Subsequent elements in the cell array are the arguments to pass to the callback function.

    • Character vector containing a valid MATLAB expression (not recommended). MATLAB evaluates this expression in the base workspace.

    For more information about specifying a callback as a function handle, cell array, or character vector, see Callbacks in App Designer.

    This property specifies a callback function to execute when MATLAB deletes the object. MATLAB executes the DeleteFcn callback before destroying the properties of the object. If you do not specify the DeleteFcn property, then MATLAB executes a default deletion function.

    If you specify this property as a function handle or cell array, you can access the object that is being deleted using the first argument of the callback function. Otherwise, use the gcbo function to access the object.

    Button down callback, specified as one of these values:

    • Function handle.

    • Cell array in which the first element is a function handle. Subsequent elements in the cell array are the arguments to pass to the callback function.

    • Character vector containing a valid MATLAB expression (not recommended). MATLAB evaluates this expression in the base workspace.

    For more information about specifying a callback as a function handle, cell array, or character vector, see Callbacks in App Designer.

    The ButtonDownFcn callback executes when you click the OpticalCoatingEditor object.

    Callback Execution Control

    Callback interruption, specified as "on" or "off", or as numeric or logical 1 (true) or 0 (false). A value of "on" is equivalent to true, and "off" is equivalent to false. Thus, you can use the value of this property as a logical value. The value is stored as an on/off logical value of type matlab.lang.OnOffSwitchState.

    This property determines if a running callback can be interrupted. There are two callback states to consider:

    • The running callback is the currently executing callback.

    • The interrupting callback is a callback that tries to interrupt the running callback.

    Whenever MATLAB invokes a callback while another callback is running, the newly invoked callback attempts to interrupt the running callback. The Interruptible property of the object that owns the running callback determines if interruption is allowed.

    • A value of "on" allows other callbacks to interrupt the callbacks of the object. The interruption occurs at the next point where MATLAB processes the queue, such as when there is a drawnow, figure, uifigure, getframe, waitfor, or pause command.

      • If the running callback contains one of those commands, then MATLAB stops the execution of the callback at that point and executes the interrupting callback. MATLAB resumes executing the running callback when the interrupting callback completes.

      • If the running callback does not contain one of those commands, then MATLAB finishes executing the callback without interruption.

    • A value of "off" blocks all interruption attempts. The BusyAction property of the object that owns the interrupting callback determines if the interrupting callback is discarded or put into a queue.

    Note

    Callback interruption and execution behave differently in these situations:

    • If the interrupting callback is a DeleteFcn or SizeChangedFcn callback, then the interruption occurs regardless of the Interruptible property value.

    • If the running callback is currently executing the waitfor function, then the interruption occurs regardless of the Interruptible property value.

    • Timer objects execute according to schedule regardless of the Interruptible property value.

    When an interruption occurs, MATLAB does not save the state of properties or the display. For example, the object returned by the gca or gcf command might change when another callback executes.

    Callback queuing, specified as "queue" or "cancel". The BusyAction property determines how MATLAB handles the execution of interrupting callbacks. There are two callback states to consider:

    • The running callback is the currently executing callback.

    • The interrupting callback is a callback that tries to interrupt the running callback.

    Whenever MATLAB invokes a callback while another callback is running, the newly invoked callback attempts to interrupt the running callback. The Interruptible property of the object that owns the running callback determines if interruption is permitted. If interruption is not permitted, then the BusyAction property of the object that owns the interrupting callback determines if it is discarded or put in the queue. These are the possible values of the BusyAction property:

    • "queue" — Puts the interrupting callback in a queue to be processed after the running callback finishes execution.

    • "cancel" — Does not execute the interrupting callback.

    Deletion status, represented as an on/off logical value of type matlab.lang.OnOffSwitchState.

    MATLAB sets the BeingDeleted property to "on" when the DeleteFcn callback begins execution. The BeingDeleted property remains set to "on" until the component object no longer exists.

    Before querying or modifying an object, check the value of the BeingDeleted property of the object to verify that it is not about to be deleted.

    Parent/Child

    Parent container, specified as a Figure, Panel, Tab, or GridLayout object. By default, the parent container is a new Figure object.

    UI component children, returned as an empty GraphicsPlaceholder array. Custom UI components have no children. Setting this property has no effect.

    Visibility of the object handle, specified as "on", "callback", or "off".

    This property controls the visibility of the object in the list of children for its parent. When an object is not visible in the list of children for its parent, it is not returned by functions that obtain objects by searching the object hierarchy or querying properties. These functions include get, findobj, clf, and close. Objects are valid even if they are not visible. If you can access an object, you can set and get its properties, and pass it to any function that operates on objects.

    HandleVisibility ValueDescription
    "on"The object is always visible.
    "callback"The object is visible from within callbacks or functions invoked by callbacks, but not from within functions invoked from the command line. This option blocks access to the object at the command line, but allows callback functions to access it.
    "off"The object is invisible at all times. This option is useful for preventing unintended changes to the UI by another function. Set the HandleVisibility to "off" to temporarily hide the object during the execution of that function.

    Identifiers

    This property is read-only.

    Type of UI component object, represented as the character vector "optics.ui.opticalcoatingeditor".

    Object identifier, specified as a character vector or string scalar. You can specify a unique Tag value to serve as an identifier for an object. When you need access to the object elsewhere in your code, you can use the findobj function to search for the object based on the Tag value.

    User data, specified as any MATLAB array. For example, you can specify a scalar, vector, matrix, cell array, character array, table, or structure. Use this property to store arbitrary data on an object.

    If you are working in App Designer, create public or private properties in the app to share data instead of using the UserData property. For more information, see Share Data Within a Single App Designer App.

    Examples

    collapse all

    Create an optical coating editor in a UI figure.

    fig = uifigure;
    hCoating = opticalCoatingEditor(Parent=fig)
    hCoating = 
      OpticalCoatingEditor with properties:
    
                     Coating: [1×1 opticalCoating]
        NumWavelengthSamples: 100
             NumAngleSamples: 90
              LightDirection: "medium2substrate"
                    Editable: on
           CoatingChangedFcn: ''
                    Position: [0 0 1 1]
    
      Show all properties
    
    

    The optical coating editor allows an app user to edit an existing coating or create a custom optical coating, and view its optical response.

    Create a broadband anti-reflective (AR) optical coating.

    ocBBAR = opticalCoating(Name="BBAR_4l", ...
        CoatingMaterial = ["TiO2" "SiO2"], ...
        LayerMaterialIndex = [1 2 1 2], ...
        ThicknessUnit = "nm", ...
        LayerThickness = [14.6 36.5 129.1 95.5]);

    Create an optical coating in a UI figure, and specify the optical coating to edit as the broadband AR coating, ocBBAR.

    fig = uifigure(Position=[250 50 650 700]);
    hCoating = opticalCoatingEditor(Parent=fig,Coating=ocBBAR);

    Edit Optical Coating

    To create an optical layer using a new material, in the Layer Materials section of the optical coating editor, click the plus button. In the name column of the Layer Materials table, select the newly added material and, from the drop-down list, and select Al2O3. Then, in the Layers section, click the plus button to add an Al2O3 layer on top of the topmost SiO2 layer. Change the thickness of the layer to 60 nm by specifying the value in the Thickness value as 60.

    Access Edited Optical Coating

    Extract the edited optical coating from the OpticalCoatingEditor object.

    editedBBAR = hCoating.Coating
    editedBBAR = 
      opticalCoating with properties:
    
                      Name: "BBAR_4l"
        IncidentAngleRange: [0 15]
           WavelengthRange: [300 800]
         PrimaryWavelength: 587.5618
                    Medium: [1×1 opticalMaterial]
                 Substrate: [1×1 opticalMaterial]
          CoatingMaterials: [3×1 opticalMaterial]
        LayerMaterialIndex: [1 2 1 2 3]
            LayerThickness: [14.6000 36.5000 129.1000 95.5000 60]
             ThicknessUnit: "nm"
                 NumLayers: 5
            TotalThickness: 335.7000
    
    

    Create an app that visualizes the reflectance, or power reflection coefficient, of a user-defined optical coating, updating the plot in real time as the user edits the coating in the app.

    In a file named coatingResponseApp.m, write a function that implements the app:

    • Define an optical coating input argument oc.

    • Define the range of angles and wavelengths for which you want to plot the spectral response using the variables angles and lambda, respectively.

    • Create a UI figure and grid layout. Position the opticalCoatingEditor in the first column of the UI figure, and a surface plot of Ra, the average power reflection coefficient, in the second column.

    • Set the CoatingChangedFcn property of the editor to a callback function, updateRaPlot, that updates the Coating property of the OpticalCoatingEditor when you create or edit an optical coating. For more information about callbacks, see Create Callbacks for Apps Created Programmatically.

    function coatingResponseApp(oc)
    
    arguments
        oc (1,1) opticalCoating
    end
    
    angles = 0:1:45;
    lambda = 400:10:600;
    
    fig = uifigure(Name="Coating Optical Response Visualizer",Position=[200 50 1000 700]);
    mainGrid = uigridlayout(fig,[1 2]);
    mainGrid.ColumnWidth = {"2x","1x"};
    h = opticalCoatingEditor(Parent=mainGrid,Coating=oc);
    ax = uiaxes(mainGrid);
    ax.Title.String = "Reflection Power Coefficient";
    ax.XLabel.String = "Wavelength (nm)";
    ax.YLabel.String = "Incident Angle (deg)";
    ax.ZLabel.String = "Ra";
    ax.PlotBoxAspectRatio = [1 1 1];
    
    coeffs = fresnelCoefficients(h.Coating,IncidentAngles=angles,Wavelengths=lambda);
    hLiveSurf = surf(ax,lambda,angles,coeffs.Ra)
    
    h.CoatingChangedFcn = @(hObj,~) updateRaPlot(hObj,hLiveSurf,angles,lambda);
        function updateRaPlot(h,hLiveSurf,angles,lambda)
            coeffs = fresnelCoefficients(h.Coating,IncidentAngles=angles,Wavelengths=lambda);
            set(hLiveSurf,"ZData",coeffs.Ra)
        end
    end

    Create a broadband anti-reflective (AR) optical coating.

    ocBBAR = opticalCoating(Name="BBAR_4l", ...
        CoatingMaterial = ["TiO2", "SiO2"], ...
        LayerMaterialIndex = [1 2 1 2], ...
        ThicknessUnit = "nm", ...
        LayerThickness = [14.6 36.5 129.1 95.5]);

    Launch the app and specify the broadband AR coating ocBarr as an input.

    coatingResponseApp(ocBBAR)

    More About

    expand all

    Alternative Functionality

    The OpticalCoatingEditor object enables an app user to edit existing coatings, create new coatings, and visualize optical coating performance parameters. To create a UI component that enables you to view the properties and optical response of an existing optical coating without editing it, use the OpticalCoatingPicker object, instead.

    Version History

    Introduced in R2026a