I have created the following class, which inherits both from handle and enum.
classdef ShiftType < handle
%SHIFTTYPE Defines shift per frame
properties
shift = 0
num_shifts = 0
end
enumeration
LateralCst %in meters
RadialCst % in radians
RadialVar % in beam distance ratio
LateralVar % Same. Lateral shift calculated at focus range.
end
end
If I create an instance of ShiftType and use it within a script, everything goes well. But I realized that, if I save this instance into a .mat file and then load it, its properies are set to their default value (0). Here is an example to illustrate the problem:
>> shift_type = ShiftType.RadialVar;
>> shift_type.shift = 0.5;
>> shift_type.num_shifts = 4;
>> shift_type
shift_type =
RadialVar
>> shift_type.shift
ans =
0.5000
>> save test.mat shift_type
>> clear all
>> load test.mat
>> shift_type
shift_type =
RadialVar
>> shift_type.shift
ans =
0
How can I have the properties saved in the .mat files along with the ShiftType instance? Note that those properties are independant of the Enum type, so I don't want to just have a ShiftType(val) function and default values for each enum (such as LateralCst (1, 4)).
Thanks ahead!
saveoborloadobjis not possible for enums and I don't know any alternative to manipulate the save / load process. I recommend to contact the support, it is definitely a bug. - Daniel