Why do I get an "Error using sort" message when calling the "intersect" method on two enumeration arrays in MATLAB R2023a?
Show older comments
I create an Enumeration class called DayOfWeek. Here is the code for the DayOfWeek class.
classdef DayOfWeek
properties
isWeekday logical
end
% CONSTRUCTOR METHOD
methods
function EnumObj = DayOfWeek(isWeekdayValue)
EnumObj.isWeekday = isWeekdayValue;
end
end
enumeration
Monday (true),
Tuesday (true),
Wednesday (true),
Thursday (true),
Friday (true),
Saturday (false),
Sunday (false)
end
end
I then create two enumeration arrays in the MATLAB Command Window.
>> onsiteDays = [DayOfWeek.Tuesday DayOfWeek.Thursday];
>> weekdays = [DayOfWeek.Monday DayOfWeek.Tuesday DayOfWeek.Wednesday DayOfWeek.Thursday DayOfWeek.Friday];
The two arrays are created successfully, but why am I getting the following error message when I call the "intersect" method on them? Is this a bug in MATLAB?
>> intersect(onsiteDays, weekdays)
Error using sort
Incorrect number or types of inputs or outputs for function 'sort'.
Error in unique>uniqueR2012a (line 208)
sortA = sort(a);
Error in unique (line 103)
[varargout{1:nlhs}] = uniqueR2012a(varargin{:},true,true,false);
Error in intersect>intersectR2012a (line 226)
c = unique(b(ismember(b,a)));
Error in intersect (line 111)
[varargout{1:nlhs}] = intersectR2012a(varargin{:});
Accepted Answer
More Answers (0)
Categories
Find more on Shifting and Sorting Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!