group data into categories which display the category name

2 ビュー (過去 30 日間)
Ollie Bliss
Ollie Bliss 2013 年 7 月 2 日
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 Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by