Error setting property 'Prop1' of class 'MyClass':
Value must not be NaN.
When you assign a value to the property, MATLAB calls mustBeNonNan with the value being assigned to the property. mustBeNonNan issues an error because division of 0 by 0 is NaN.
Restrict Function Argument Values
This function declares an input argument that must be a vector of doubles containing no NaN elements.
function s = mbNonNan(x)
arguments
x (1,:) double {mustBeNonNan}end
n = length(x);
m = sum(x)/n;
s = sqrt(sum((x-m).^2/n));
end
Calling the function with an input that does not meet the requirement of mustBeNonNan results in an error.
values = [12.7, 45.4, 98.9, NaN, 53.1];
s = mbNonNan(values);
Error using mbNonNan
Invalid input argument at position 1. Value must not be NaN.