function savedata = saveobj(obj)
%

% Help is inherited from superclass

%   Copyright 2019-2021 The MathWorks, Inc.

% Create a structure for saving
savedata.IsBlank = isblank(obj);
if savedata.IsBlank
    savedata.SupportsClassFrom = 2;
    internalBlank = gatherData(obj.FormattedData);
    savedata.Size = size(internalBlank);
    savedata.DataType = internalBlank.EmptyData;
else
    savedata.Data = gatherData(obj.FormattedData);
end

savedata.DimensionTypes = obj.FormattedData.DimensionMetadata;
savedata.ViewPermutation = obj.ViewToDataMap;

% Tag saved data with object version that created it
savedata.ClassVersion = dlarray.ClassVersion;

% Tag saved data with earliest previous version that we know will be able
% to load the structure in a way that will seem correct for that version.
% (Some features may be lost, but data will be correct)
if savedata.IsBlank
    savedata.SupportsClassFrom = 2;
else
    savedata.SupportsClassFrom = 1;
end
