group data into categories which display the category name

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

Réponses (1)

Azzi Abdelmalek
Azzi Abdelmalek le 2 Juil 2013
Modifié(e) : Azzi Abdelmalek le 2 Juil 2013
data=[25 90 95 185 275 360];
s='ABCD',
idx=ceil(data/90)
idx(idx==0)=1;
out=s(idx)

Catégories

En savoir plus sur Loops and Conditional Statements dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by