MATLAB Migration Guide
This guide is for users who wish to migrate a project from using our legacy MATLAB package to the new one. Each section below covers a difference in the two package's APIs.
Enums and Units
In the new package, unit and enum names have been updated to align with MATLAB's enum documentation. This means that in your codebase, you will have to change Zaber Motion Library enums from SCREAMING_SNAKE_CASE to TitleCase. For example:
In the legacy package:
myUnit = zaber.motion.Units.LENGTH_MILLIMETRES;
mode = zaber.motion.product.ProcessControllerMode.PID_HEATER;
In the new package:
myUnit = zaber.motion.Units.LengthMillimetres;
mode = zaber.motion.product.ProcessControllerMode.PidHeater;
Additionally, the Units type in the new package contains dictionaries which can be used to specify units by their 'short names'.
In the legacy package:
myUnit = zaber.motion.Units.ACCELERATION_MILLIMETRES_PER_SECOND_SQUARED;
In the new package (all three are equivalent):
myUnit1 = zaber.motion.Units.AccelerationMillimetresPerSecondSquared;
myUnit2 = zaber.motion.Units.Acceleration("mm/s²");
myUnit3 = zaber.motion.Units.Acceleration("mm/s^2");
Class Property Getters and Setters
The legacy package uses Java-style getter and setter methods for class properties. The new one uses MATLAB class properties.
In the legacy package:
allAxes = device.getAllAxes();
scope = microscope.getScope();
In the new package:
allAxes = device.AllAxes;
scope = microscope.Scope;
Name-Value Arguments
The new library takes advantage of MATLAB's syntax for specifying optional arguments as name-value pairs. These arguments can be passed out of order, unlike in the legacy library where if a user wants to specify a value for the nth optional argument, they would have to pass values for all the preceding arguments. If you only want to pass position and acceleration values to Axis.moveAbsolute for example.
In the legacy package:
import zaber.motion.Units;
import zaber.motion.Measurement;
axis.moveAbsolute(2, Units.LENGTH_MILLIMETRES, true, 0, Units.NATIVE, 0.1, Units.ACCELERATION_MILLIMETRES_PER_SECOND_SQUARED);
In the new package:
import zaber.motion.Units;
import zaber.motion.Measurement;
axis1.moveAbsolute(2, Units.LengthMillimetres, acceleration=0.1, accelerationUnit=Units.Acceleration("mm/s²"));