Input Argument Validation Issue
I’m having an issue with input argument validation using the arguments block. Here’s a simplified version of my code
function plot(obj, diagramType)
arguments
obj (1,:)
diagramType (1,:) {mustBeMember(diagramType,{"Flow Rate", "Velocity"})} = "Flow Rate";
end
end
I’m trying to override the plot command for a class of objects, but when I call this plot function, I get the following error:
Error using FundamentalDiagram/plot (line 17)
Invalid default value for argument ‘diagramType’. Value must be members of the required set.
This is confusing because it seems like the default value I chose – "Flow Rate" is clearly in the required set. What could this issue be?I’m having an issue with input argument validation using the arguments block. Here’s a simplified version of my code
function plot(obj, diagramType)
arguments
obj (1,:)
diagramType (1,:) {mustBeMember(diagramType,{"Flow Rate", "Velocity"})} = "Flow Rate";
end
end
I’m trying to override the plot command for a class of objects, but when I call this plot function, I get the following error:
Error using FundamentalDiagram/plot (line 17)
Invalid default value for argument ‘diagramType’. Value must be members of the required set.
This is confusing because it seems like the default value I chose – "Flow Rate" is clearly in the required set. What could this issue be? I’m having an issue with input argument validation using the arguments block. Here’s a simplified version of my code
function plot(obj, diagramType)
arguments
obj (1,:)
diagramType (1,:) {mustBeMember(diagramType,{"Flow Rate", "Velocity"})} = "Flow Rate";
end
end
I’m trying to override the plot command for a class of objects, but when I call this plot function, I get the following error:
Error using FundamentalDiagram/plot (line 17)
Invalid default value for argument ‘diagramType’. Value must be members of the required set.
This is confusing because it seems like the default value I chose – "Flow Rate" is clearly in the required set. What could this issue be? function, arguments, validation MATLAB Answers — New Questions