matlab-model-optics
Build, import, analyze, tolerate, and optimize optical systems using the Optical Design and Simulation Library
Install / Use
npx skills add matlab/matlab-agentic-toolkit --skill matlab-model-opticsInstalls into whichever agent you are using.
SKILL.md
Installable skill definition
Quality Score
Category
Development & EngineeringSupported Platforms
Our assessment of matlab-model-optics
matlab-model-optics scores 90/100 on our quality scale, 1536th of 4,582 Development & Engineering skills we index (top 34%).
Its SKILL.md is 15 KB long, well organised into 33 sections with 21 code examples: a thorough specification that gives an agent plenty to work with.
With 1,098 GitHub stars, it is one of the more widely adopted skills in the catalogue.
Maintenance, license and trust
- The repository was last updated 21 days ago, so matlab-model-optics is actively maintained.
- No license is declared. By default that means all rights are reserved: you can read it, but reusing or redistributing it is not clearly permitted. Ask the author before building on it commercially.
- Its trust signals score 88/100, with 1 caution from licensing, adoption, age or documentation. These come from repository metadata, not a code audit — read the skill file before letting an agent act on it.
matlab-model-optics compared with similar skills
All 4 of these similar skills score higher than matlab-model-optics; compare them before choosing.
| Skill | Score | Stars | Updated | Format |
|---|---|---|---|---|
| matlab-model-optics (this skill)by matlab | 90 | 1.1k | 21d ago | SKILL.md |
| ai-job-searchby MadsLorentzen | 100 | 45.1k | 1d ago | CLAUDE.md |
| claude-howtoby luongnv89 | 100 | 41.8k | 6d ago | CLAUDE.md |
| algorithmic-artby anthropics | 100 | 177.9k | 14d ago | SKILL.md |
| pptxby anthropics | 100 | 177.9k | 14d ago | SKILL.md |
Frequently asked questions
- How do I install matlab-model-optics?
- Run
npx skills add matlab/matlab-agentic-toolkit --skill matlab-model-optics. The install tabs above show the steps for each supported agent. - Which AI agents does matlab-model-optics work with?
- It is written for Universal, as a SKILL.md file. Other agents that read the same format can often use it too.
- Is matlab-model-optics safe to use?
- It declares no license and scores 88/100 on trust signals. Skills are instructions an agent will follow, so read the file before installing it and do not approve commands you do not understand.
- Is matlab-model-optics still maintained?
- The repository was last updated 21 days ago, so matlab-model-optics is actively maintained.
Skill content
View source on GitHubname: matlab-model-optics description: > Build, import, analyze, tolerate, and optimize optical systems using the Optical Design and Simulation Library. Use when the user asks about optical systems, ray tracing, geometric optics, Zemax import, optical coatings, tolerancing, or optical design optimization. license: https://www.mathworks.com/content/dam/mathworks/license/pmrl/license.md metadata: author: MathWorks version: "1.0"
Optical Design and Simulation Library
Use this skill when the user is working with the Optical Design and Simulation Library to build, import, analyze, tolerate, or optimize optical systems in MATLAB.
This library may also be referred to as:
- Optical Design and Simulation Library
- Optics Support Package
- Optics Add-On
- Optics Library
- Optics Toolbox
Use Optical Design and Simulation Library as the canonical name in responses unless the user explicitly uses a different name.
When to Use
Use this skill when the user asks about:
- Optical Systems
- Ray Tracing
- Geometric Optics based analysis like lens distortion, spot diagrams, chromatic aberration, astigmatism and ray fans
- Paraxial Optics
- Optical Coatings
- Polarization or EM analysis (computing Fresnel Coefficients)
- Glass Materials and Glass Catalogs
- Zemax import
- Optical Tolerancing
- Optical System Design and Optimization
- Dynamic optical systems in Simulink (see
references/dynamic-optical-systems-simulink.md)
When NOT to Use
Do not use this skill when:
- The user is working with physical optics or wave optics (diffraction, interference, coherence)
- The user is working with fiber optics or photonics
- The user needs image processing or computer vision (use Image Processing Toolbox instead)
- The task is purely about Simulink modeling without optical system involvement
First Steps
When helping a user who is new to the library, start with discovery:
help optics
To get more details for a specific function:
help lensDistortion
doc lensDistortion
Many optics APIs are class methods. For class methods, use:
help className/functionName
doc className/functionName
Example:
help opticalSystem/add
Use examples in the documentation when the user asks for a larger end-to-end workflow.
Sample ZMX Files
The Optical Design and Simulation Library ships sample Zemax (.zmx) files in the opticsdata folder within the support package install location. To find the path:
spkgRoot = fullfile(matlabshared.supportpkg.getSupportPackageRoot, "toolbox", "images", "supportpackages", "opticsdata");
dir(fullfile(spkgRoot, "*.zmx"))
When a user asks to work with a standard optical system (e.g., "a Cooke triplet", "a doublet", "a telephoto lens") but does not provide their own file:
- List the available
.zmxfiles in theopticsdatafolder - Pick the sample system that best matches the user's request
- Import it using
zmximport
This avoids asking the user for a file path when a suitable sample already exists.
Core Concepts
opticalSystem
opticalSystem is the central object representing a physical optical system.
opsys = opticalSystem(Wavelengths=[486.134 587.562 656.281]);
opticalMaterial
opticalMaterial represents a glass or optical material.
mat = opticalMaterial([1.5168 64.17]);
mat = pickGlass("N-BK7");
opticalCoating
opticalCoating represents a thin-film coating applied to surfaces.
oc = opticalCoating(CoatingMaterial=["MgF2" "TiO2"], LayerMaterialIndex=[1 2 1 2], LayerThickness=[1 0.5 1 0.5], PrimaryWavelength=550);
oc = pickCoating("AR_MgF2_VIS");
addCoating(opsys, oc);
addCoating(opsys, oc, CoatingSide="front");
Coordinate Systems
Refer to the MATLAB Documentation page called "Coordinate Systems in Optical Design" to learn about the coordinate system conventions used to construct optical systems.
Field Point Angle Convention
When creating a field point with fieldPoint(Angles=[Hy Hx]):
Hy— vertical field angle (degrees)Hx— horizontal field angle (degrees)
Example — a field point at 10 degrees vertical:
fp = fieldPoint(Angles=[10 0]);
A field point at 10 degrees horizontal:
fp = fieldPoint(Angles=[0 10]);
TiltAngles Convention
TiltAngles=[Rx Ry Rz] specifies rotations in degrees about each axis:
Rx(first element) — rotation about the X-axisRy(second element) — rotation about the Y-axisRz(third element) — rotation about the Z-axis
Example — a mirror tilted 45 degrees about the X-axis:
addMirror(opsys, TiltAngles=[45 0 0]);
Common Interaction Patterns
Pattern: Build → Visualize → Analyze
Many user requests follow this sequence:
- Build or import an optical system
- Define field points and wavelengths
- Run an analysis function
- Inspect returned values
- Visualize results
%% 1. Build
opsys = opticalSystem(Wavelengths=587.562);
addRefractiveSurface(opsys, Radius=50, Material=pickGlass("N-BK7"), SemiDiameter=10, DistanceToNext=5);
addRefractiveSurface(opsys, Radius=-50, SemiDiameter=10, DistanceToNext=20);
addImagePlane(opsys, SemiDiameter=10);
opsys.FieldPoints = fieldPoint(Angles=[0 0; 10 0]);
%% 2. Visualize
h2 = view2d(opsys);
%% 3. Analyze
tra = rayAberration(opsys);
hra = show(tra);
Pattern: Compute → Show
Many analyses follow a compute first, visualize second pattern.
spotResult = spot(opsys);
spotDiagram(spotResult);
ldResult = lensDistortion(opsys);
show(ldResult);
Use this pattern when the user wants both a numeric result and a plot.
Pattern: Fresh Copy of Optical System
Explicitly create a fresh copy of the original system if you want to use it as a starting point for multiple different changes. This is particularly useful for tolerancing and sensitivity analysis, where parameters of the original system are mutated repeatedly.
newSys = copy(opsys);
This avoids accumulating perturbations across trials unless accumulation is explicitly intended.
Task: Construct Optical System from Prescription Table
Sequential optical systems are often specified as prescription tables (common in patent documents, textbooks, and optical design references).
Each row represents a surface or optical element, with columns such as:
- Radius of curvature
- Thickness to next surface
- Material (name or [nd, vd])
- Surface type (implicit or explicit, e.g., stop or image plane)
Users may provide this data as a screenshot, an Excel sheet, or a manually entered table.
Example Prescription Table (Explicit Stop Surface)
| Surface | Radius | Thickness | Material | Type | |--------|--------|----------|----------|------| | 1 | 50 | 5 | N-BK7 | Refractive | | 2 | -50 | 5 | Air | Refractive | | 3 | — | 5 | — | Stop | | 4 | 40 | 5 | N-BK7 | Refractive | | 5 | -40 | 20 | Air | Refractive | | 6 | Inf | 0 | Image | ImagePlane |
Pattern: Table → Optical System
- Create
opticalSystem - Iterate over rows
- For each row:
- Refractive →
addRefractiveSurface - Stop →
addDiaphragm - ImagePlane →
addImagePlane
- Refractive →
- Use thickness as
DistanceToNextfor preceding element
Example Code
opsys = opticalSystem(Wavelengths=587.562);
% Surface 1
addRefractiveSurface(opsys, Radius=50, Material=pickGlass("N-BK7"), DistanceToNext=5);
% Surface 2
addRefractiveSurface(opsys, Radius=-50, DistanceToNext=5);
% Stop (explicit element)
addDiaphragm(opsys, DistanceToNext=5);
% Surface 4
addRefractiveSurface(opsys, Radius=40, Material=pickGlass("N-BK7"), DistanceToNext=5);
% Surface 5
addRefractiveSurface(opsys, Radius=-40,DistanceToNext=20);
% Image plane
addImagePlane(opsys);
h2initial = view2d(opsys, Parent=figure);
Update Semi Diameters of Surfaces
The semi-diameters of all the surfaces is set to the default value because the table does not provide this value. Instead, system descriptions usually provide a field of view (FOV).
Pattern: Set Semi-Diameters from Field of View
After building the optical system:
- Use the field of view to define the target field angle
- Identify the aperture constraint from the system description. See
help updateSemiDiametersfor valid constraint options. - Call updateSemiDiameters to compute semi-diameters for all surfaces
FOV = 20; % degrees
targetFieldAngle = FOV / 2;
updateSemiDiameters(opsys, "EntryPupilRadius", 5, TargetFieldAngle=targetFieldAngle);
h2Final = view2d(opsys, Parent=figure);
Task: Create systems using components
Users often build optical systems by combining off-the-shelf components (e.g., vendor-provided designs such as singlets, doublets, or lens groups).
This workflow involves:
- importing existing designs
- modifying system structure
- explicitly managing gaps between components
Pattern: Extend System with Component
- Load the components or systems that will be used to construct the base system
- Remove terminal components if needed (e.g., image plane)
- Explicitly update gaps as removing components does not update the gap
- Create the base system opticalSystem
- Add loaded components one by one to the base system and set the gap between components suitably
Example Code
% Load existing system
opsysCooke = zmximport("CookeTriplet.zmx");
% Step 1: Remove image plane (if present)
remove(opsysCooke);
% Step 2: Removing a component does NOT remove the gap. Zero out the trailing gap
changeGap(opsysCooke, numel(opsysCooke.Components), 0);
% Step 3: Import singlet component
opsysSinglet = zmximport("singlet.zmx");
% Step 4: Create a new optical System with these two
opsys = opticalSystem(Name="Combined System");
add(opsys, opsysCooke);
changeGap(opsys, numel(opsys.Components), 3, GapLocation="after");
% Step 4: Append singlet to system
add(opsys, opsysSinglet);
h2 = view2d(opsys);
Task: Add Mirrors or Folded Geometry
Use addMirror when the user wants to model reflective systems.
Example: Periscope system with mirrors at 45 degrees
This periscope folds the beam in the Y-Z plane using X-axis rotations:
opsys = opticalSystem();
addMirror(opsys, Radius=0, SemiDiameter=10, TiltAngles=[45 0 0]);
addGap(opsys, 50);
addMirror(opsys, Radius=0, SemiDiameter=10, TiltAngles=[-45 0 0]);
addGap(opsys, 20);
addImagePlane(opsys, SemiDiameter=10);
h = view2d(opsys);
addRays(h);
To fold in the X-Z plane instead, use Y-axis rotations: TiltAngles=[0 45 0].
Task: Use Ray Data
Use this when the analysis user is looking for is not available out of the box and the user has to derive it themselves using the RayData that is available as part of the RayBundle.
Pattern — plot incident angles on a specific surface using pupil coordinates:
% Import a Cooke triplet
opsys = zmximport("CookeTriplet.zmx");
% Trace from 10-degree field point with incident angle data
fp = fieldPoint(Angles=[10 0]);
sg = samplingGrid("Hexapolar", 8);
rb = traceRays(opsys, FieldPoints=fp, Wavelengths=587.562, SamplingGrid=sg, RayProperties="IncidentAngle");
rd = rb(1).RayData;
% OrientedGrid gives normalized pupil XY for each ray
xy = rd.OrientedGrid;
% Incident angles on surface 4
angles = rd.IncidentAngle(:, 4);
% Scatter plot: position from pupil grid, size and color from angle
figure;
scatter(xy(:,1), xy(:,2), abs(angles)*5, angles, 'filled');
colorbar;
xlabel("Pupil X"); ylabel("Pupil Y");
title("Incident Angle on Surface 4 — Field Angle 10°");
axis equal;
Task: Optimize a Design
Use design optimization when the user wants to improve performance starting from an initial optical system. See references/optical-system-design.md for detailed patterns, code templates, and optimizer selection guidance.
General workflow:
- Define an initial optical system
- Pack design variables (radii, thicknesses, materials, gaps) into a nu
Truncated for display — read the full file on GitHub.
Related Skills
ai-job-search
45.1kThe job search that runs on your machine. AI job application framework built on Claude Code: evaluate postings, tailor CVs, write cover letters, prep interviews. Fork it and own it.
claude-howto
41.8kA visual, example-driven guide to Claude Code — from basic concepts to advanced agents, with copy-paste templates that bring immediate value.
algorithmic-art
177.9kCreating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code, generative art, algorithmic art, flow fields, or particle systems.
pptx
177.9kUse this skill any time a .pptx or .potx file is involved in any way — as input, output, or both. This includes: creating slide decks, pitch decks, or presentations; reading, parsing, or extracting text from any .pptx or .potx file (even if the extracted content will be used elsewhere, like in an em…
Languages
Trust signals
From repository metadata: license, adoption, age and documentation. Not a code audit — see the Safety scan above for what the skill file itself contains.
