Categorizing array elements based on percentage
显示 更早的评论
I have an array, whose odd indices are to be divided into 4 categories based on some predefined percentage.For example, say X = [1,2.....20],odd_ind = [1 3 5...17 19], among which the first 40% are to be categorized as 1, next 30% as 2, next 20% as 3 and next 10% as 4.Could anyone guide me through this?I am a beginner and need some help with this.
Thanks in advance.
3 个评论
AJAY CHANDRA DORAGARI
2020-6-25
first take all the odd indices out and form a matrix and then use logical opertion on the matrix
with first category say a<=0.4&a>0.3 you'll get the logical array which helps in getting elements out
second category say a<-30&a>20
and so on
i guess this will work
try this
unless you are specific i cant help you
Walter Roberson
2020-6-26
Is that first 40% and so on by value, or by index?
KK14
2020-6-26
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Categorical Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!