r/Optics • • 7d ago

Optical System Design and Analysis in MATLAB R2026b R2026b

I posted about optics in MATLAB R2026a earlier, back now to give you an update on the R2026b version!

At the lowest level, we now support biconic and Grid surface specifications for both mirrors and lenses. The grid sag is the swiss army knife to model any free form optical surface! It uses bilinear interpolation under the hood and its ray intersection implementation is quite performant. So in addition to 'as built' surface modelling, try it out for modelling XY Polynomials or Zernike surface definitions (meshgrid is your friend :)).

We added a couple more basic low level ray tracing routines: traceDirectedRays and traceAimedRay. Both return rich RayData which has all raw ray tracing numbers (including fresnel terms and raw polarization values).

We rounded out analysis functions by adding PSF (Geometric and Huygens, GPU Accelerated!), MTF and OPD measurement functions.

A couple of marquee features this release - the main being CLI routines for tolerancing:

Find Manufacturing Tolerances Using Inverse Sensitivity Analysis

Forward Sensitivity

Improve Manufacturing Yield Using Monte Carlo Analysis

MC Yield Curve

And the second is the ability to simulate eSFR and Color checker test charts as seen through an optical system.

Rendering of a simulated eSFR chart through an optical system
Rendering of a simulated Color Checker chart through an optical system

These charts leverage the established Image Processing Toolbox functions to measure sharpness and color. The main function to create these, renderChart, can leverage the GPU and has various parameters to control the positioning of the chart. The GPU acceleration is important since this does the full Monte Carlo ray trace of the scene.

We also have a whole bunch of featured examples! Not only do these help us dog food and validate our API designs, it also helps us show you what is possible. If any of these resonate, let us know - that would motivate us to fold these in as first class API's with potentially better (tailored) performance.

For example 😄, the inbuilt chart rendering function mentioned above work on an internal parametric chart model so it cannot be used to render arbitrary images. However, we can simulate a user image using spatially varying PSFs - shown here: Simulate Image Using Spatially Variant PSF. This is much faster than a full ray render like the charts.

Simulated rendering of an image using spatially varying PSF kernels

This one shows off both the Grid surface and OPD functionality: Model Shack-Hartmann Wavefront Sensor

Microlens array for a Shack-Hartmann Wavefront sensor

And if you use Simulink based control systems, we show you a way to model dynamic systems with feedback control! Model Dynamic Optical Systems with Scanning Elements shows an f-theta scanning system controlled by a Simulink model.

Simulink control of a F-theta scanning mirror lens system

Finally, something I really enjoyed learning about and putting together - a set of examples modelling the human eye.
Create Human Eye Model Schematic
Model Human Eye Diopters, Accommodation, and Refractive Errors
Simulate Human Eye Changes with Age
Model Progressive Addition Lens Using Presbyopic Eye Model

Modelling a Human Eye with a Progressive Lens

Kick the tires with a trial license, or if you already have 26b with the Image Processing Toolbox, get this free optics add-on.

Let us know what you think!

If you have a must-have workflow, share it in the comments.
If its doable, I'll let you know and if not ... I'll let the team know 😄!

33 Upvotes

20 comments sorted by

3

u/Equivalent_Bridge480 7d ago

what price of matlab + Simulink  for running this toolbox?
how you verified if software correct?

3

u/BlueHash4 6d ago

This is currently a free 'add-on' if you have Image Processing Toolbox on your license. Our general prices (e.g for Image Processing Toolbox) are here: https://www.mathworks.com/store/ (depends on the type of license).

Verification - multiple ways. Most (basics) can be tested with known/hand computed ground truth, and then we build on that. We also use a bunch of reference text books to validate designs and higher analysis results. In addition, we have commercial and academic adopters that we have developed a partnership to get continuous early feedback and validation.

2

u/Equivalent_Bridge480 6d ago

I dont have matlab. this reason why I questioned.

"Most (basics) can be tested with known/hand computed ground truth, and then we build on that."
that is interesting. which devices builded based on your software?

Could you share some of these adopters as references?

3

u/BlueHash4 6d ago

My bad, I was not clear. I meant we can build additional tests on top of the basic tests, e.g we can hand compute Snell's law for basic surfaces, then for verifying spot we can take the local hit points as 'tested'. Or say once we hand compute for spherical surfaces - we can test Grid surfaces seeded with a spherical shape (With increasing Grid sampling, we should get into floating point tolerances with pure spherical) .

Not yet. We are working on getting permissions from them. We (in general) publish customer stories and technical articles here: https://www.mathworks.com/company/technical-articles.html?q=&fq%5B%5D=marketing-source:customer&page=1 (but this takes time to put together, so we (optics) are not there yet).

2

u/Twinson64 7d ago

Cool :)

2

u/Thick-Panic6683 7d ago

The mathworks page shows a 3D view of an optical system. Is it possible to do non-sequential modeling with ray trace and light scattering simulation, like Zemax? Seems like it would be within reach if you don't already have it.

3

u/BlueHash4 6d ago

Not in R2026b. Our current aim is to build a solid foundation first and then depending on user requests, evolve.

Would you mind outlining a few usecases? I frequently see two definitions of non-sequential - one feels truly 'non-sequential', like illumination/lighting for designing things like automotive light housings. And another, feels a bit like 'multi sequential', i.e think of a laser system with beam splitters and multiple detectors. The latter feels more like a deterministic set of sequential systems, with only the initial step of determining these sub-systems needing a true non-sequential trace.

3

u/Thick-Panic6683 6d ago edited 6d ago

I have used non-sequential mode for illumination visualization as well as laser system analysis through mirror arrangements. I would set up detector screens to capture light scattering hits on the detector. From this would make animations by moving components in 3D and capturing the detector screens. Also used merit functions to walk a laser beam to a detector point. One utility I wrote in Matlab used the keyboard arrow keys to walk laser beams through mirror combinations.

But often I used it to visualize 3D optical systems from CAD models for marketing and proposal work. What I am thinking is a CAD geometry kernal that imports STEP/STL optical component models and runs a ray trace through that to produce good graphics. I have considerd possible open-source solutions. (this is almost just an intellectual exercise as the level of effort exceeeds the possible user base).

I posed the questions to Chat GPT given your toolkit and available geometry engines for Matlab. The OpenCascade kernel may be an option for you to consider. I can share that chat with you by DM if you are interested. It provides an architecture for how that could be achieved and level of effort required.

1

u/BlueHash4 6d ago

I would be interested in workflows/usecases for sure! Especially the laser system analysis. Feel free to DM.

2

u/Thick-Panic6683 6d ago

I DM'd the chatgpt thread. My laser analysis was often very simplistic; just visualize where the beam is hitting after encountering mirrors and other components. I would build a 3D model in Zemax (by importing CAD STEP files) and use whatever sources might approximate the laser. In my work I encountered engineers developing industrial laser welding/cutting systems who had no background in optical layout and modeling.

1

u/Equivalent_Bridge480 6d ago

stray light

1

u/BlueHash4 6d ago

Thank you! What would you consider is the current 'best approach' for stray light analysis? Do you use any particular tool that is well suited for it now?

1

u/Equivalent_Bridge480 6d ago

Not sure what mean best approach. Each system and engineer have own best way. And probably noone will share spmething important with competitoers and llm which collect data from reddit for *0 m dollars per year.

I using zemax. And if your question what is problems with it - zemax dont convert nsc to sc.

2

u/BlueHash4 5d ago

I understand what you mean. Thanks for sharing the nsc->sc pain.

I think MATLAB is well suited here in the sense that you would (eventually) have all the basic blocks (even beyond optics!) - so each expert could put together/experiment with their own unique workflows.

1

u/lancerusso 6d ago

The latter would often be named ''zooms'.

2

u/lancerusso 6d ago

Can it read in CODE V files (.SEQ) yet?

5

u/BlueHash4 6d ago

Not yet.

We currently support ZMX import, mainly because we had access to known good designs so we could validate the import process. Its not an explicitly defined format, so we could still be missing edge cases!

We have some customers asking us for .SEQ import - but we dont yet have enough samples to be confident we understand the format. Open to suggestions if you have references! Or DM me and we can connect officially if you are in a position to share.

3

u/lancerusso 6d ago

Particularly interesting is use of INT (interferogram (usually zernike) on a surface), which is how CODE V does tolerancing these days.

CODE V documents most (if not all) of the .SEQ commands. SEQ is a sequential command file used to reconstruct a system design, so it should be easier than e.g. a closed source binary file that stores a design.

3

u/BlueHash4 6d ago

Thank you! Interoperability is important, I'll bring this to the team.

1

u/nian2326076 6d ago

That's awesome that R2026b is adding more to the biconic and grid surface specs. If you're getting ready for interviews or just want to talk about this in a technical setting, focus on how these new features can solve real-world problems in optical system design. Make sure you know the practical uses and limits of these specs. For interviews, it might help to talk about how you've used these tools in past projects or plan to use them in the future. If you need more detailed interview prep, I've found PracHub helpful for brushing up on technical concepts. Good luck!