When trying to create a statevector build from both spatial data (e.g. a spatial field with lat and lon) and a pre-computed mean value (e.g. a cosine-weighted Hemisphere mean), the presence of single precision data classes in the latitude and longitude in the metadata can cause an error in cell2mat when calling statevector.build.
This appears to be because dimensionless dimensions (e.g. 0x0 or []) are double class - prior to R2025a (when cell2mat became more forgiving), sv.build will fail with a 'All contents of the input cell array must be of the same data type' error from cell2mat.
The fix is to cast the coordinates or latWeights to double before passing to weightedMean for safety:
latWeights = double(cosd(meta.lat(extratropical)));
or do this in weightedMean.m itself:
obj.weights{d} = double(weights{k}(:))
When trying to create a statevector build from both spatial data (e.g. a spatial field with lat and lon) and a pre-computed mean value (e.g. a cosine-weighted Hemisphere mean), the presence of single precision data classes in the latitude and longitude in the metadata can cause an error in cell2mat when calling statevector.build.
This appears to be because dimensionless dimensions (e.g. 0x0 or []) are double class - prior to R2025a (when cell2mat became more forgiving), sv.build will fail with a 'All contents of the input cell array must be of the same data type' error from cell2mat.
The fix is to cast the coordinates or latWeights to double before passing to weightedMean for safety:
latWeights = double(cosd(meta.lat(extratropical)));
or do this in weightedMean.m itself:
obj.weights{d} = double(weights{k}(:))