Group values of a vector into new vectors according to magnitude
1 次查看(过去 30 天)
显示 更早的评论
I have a vector A with different values of angles:
A = [17 323 100 3 278 220 45 351 212 51]
what I need is to group all angles between 0 and 50° into a new vector called B, all angles between 50° and 100° into a new vector called C, and all angles between 100° and 360° into a new vector called D.
How can I achieve that?
0 个评论
采纳的回答
Chunru
2021-9-17
A = [17 323 100 3 278 220 45 351 212 51]
B = A(A>=0 & A<50)
C= A(A>=50 & A<100)
% Leave D for you
0 个评论
更多回答(1 个)
Jan
2021-9-17
A = [17 323 100 3 278 220 45 351 212 51];
Y = discretize(A, [0, 50, 100, 360])
C = splitapply(@(x) {x}, A, Y)
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Numeric Types 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!