group data into categories which display the category name

1 次查看(过去 30 天)
I have a 26,000 long dataset of degrees (angle 0-360).
I want these categories 0-90 = A 90-180 = B 180-270 = C 270-360 = D
(A, B, C, D are strings).
what loop do I need to run through the data set and display the four letter for each category. I.e. to form the dataset:
A C D B B B A D C D D D C C A B D C D A .............. etc

回答(1 个)

Azzi Abdelmalek
Azzi Abdelmalek 2013-7-2
编辑:Azzi Abdelmalek 2013-7-2
data=[25 90 95 185 275 360];
s='ABCD',
idx=ceil(data/90)
idx(idx==0)=1;
out=s(idx)

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by