matlab-model-optics

Build, analyze, tolerate, and optimize optical systems and coatings in MATLAB.

995|122|Updated Apr 3, 2026
One-click install
npx skills add https://github.com/matlab/matlab-agentic-toolkit --skill matlab-model-optics
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: matlab-model-optics
Source: https://github.com/matlab/matlab-agentic-toolkit/tree/main/skills-catalog/image-processing-and-computer-vision/matlab-model-optics
Command: npx skills add https://github.com/matlab/matlab-agentic-toolkit --skill matlab-model-optics

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Designing optical systems in MATLAB requires knowing the Optical Design and Simulation Library's object model, coordinate conventions, and analysis workflows. This Skill gives an AI agent the domain knowledge to construct systems from prescription tables, import Zemax files, run ray-tracing analyses, and set up optimization and tolerancing studies without hallucinating functions.

Core Features & Use Cases

  • Optical System Construction: Build sequential systems from prescription tables, combine off-the-shelf components, add mirrors and folded geometry, and import Zemax (.zmx) files including shipped sample designs.
  • Analysis & Visualization: Compute spot diagrams, lens distortion, ray aberrations, and paraxial properties, and extract custom metrics from RayBundle data.
  • Optimization & Tolerancing: Structure design optimization with merit functions and bounded optimizers, design thin-film coatings, and run Monte Carlo yield or sensitivity analyses.
  • Use Case: Ask the agent to import a Cooke triplet sample, set semi-diameters from a 20-degree field of view, trace rays, and plot the spot diagram — it produces correct idiomatic MATLAB code end to end.

Quick Start

Use the matlab-model-optics skill to import the sample Cooke triplet Zemax file, set the field of view to 20 degrees, and plot a spot diagram.

Frequently Asked Questions about matlab-model-optics

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I import a Zemax file into MATLAB?

Use zmximport to load a .zmx file into an opticalSystem object, for example opsys = zmximport("CookeTriplet.zmx"). The Optical Design and Simulation Library also ships sample .zmx files in the opticsdata support package folder for common systems like Cooke triplets and doublets.

How do I build an optical system from a prescription table in MATLAB?

Create an opticalSystem, then iterate over table rows calling addRefractiveSurface for lens surfaces, addDiaphragm for stops, and addImagePlane for the image plane, using each row's thickness as DistanceToNext. Afterwards call updateSemiDiameters with the field of view to size all surfaces.

Can I optimize an optical coating design in MATLAB?

Yes. Define coating materials with pickCoatingMaterial, pack layer thicknesses into a vector, write a merit function evaluating fresnelCoefficients against spectral band goals, and run a bounded optimizer such as lsqnonlin. The skill's references provide templates for AR coatings, bandpass, and longpass filters.

Does the Optical Design and Simulation Library support physical optics or diffraction?

No. The library covers geometric optics: ray tracing, paraxial analysis, coatings, tolerancing, and optimization. It does not handle wave optics phenomena like diffraction, interference, or coherence, nor fiber optics and photonics.

Can I use optical systems inside a Simulink model?

Yes, by calling the optics function from a MATLAB Function block with coder.extrinsic, since the library does not support code generation. Create the opticalSystem once using a persistent variable, update parameters from Simulink inputs each timestep, and return computed outputs like RMS spot size.

How do I estimate manufacturing yield for an optical coating?

Run a Monte Carlo analysis: perturb layer thicknesses and refractive indices with material-specific Gaussian sigmas, evaluate each sample with fresnelCoefficients against a pass/fail criterion, and compute the pass rate. Use parfor for the independent trials and 400 or more trials for reliable yield estimates.