value = sum(uint32(array))
Sum of enumerated data types
1 次查看(过去 30 天)
显示 更早的评论
I have an array of 50 elements all of which are enum types. (say FALSE(0), TRUE(1), UNAVAILABLE(2)). I would like to calculate the sum of the array elements. The function 'SUM' in matlab does not support enumerated datatypes. I tried using a 'for' loop and did something like this :
value = 0;
for i = 1:50
value = value + array(i);
end
But I receive an error saying code generation does not support binary operations on enums.
Is there a better way to implement this logic?
0 个评论
回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Type Identification 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!