How to organise data based on a large range of numbers?
이전 댓글 표시
I have a set of data that needs to be organised by season. Each row represents a different sample with each column representing the different data collected for each sample. Column 8 represents the day of the year the sample was collected so I want to use this to get an estimate of the season in which the sample was collected, ie. if the day of the year is from 1-59 as well as 335-366 the data was collected in summer, if the day of the year the sample was collected was between the 60th and the 151st day of the year then the sample was collected in Autumn, and so on.... As the seasons encompass numerous days of the year I have been finding it difficult to extract organise the data into seasons. I was wondering if anyone knew as to how this could be done? Thanks
채택된 답변
추가 답변 (1개)
Andrei Bobrov
2013년 10월 21일
ssn = {'summer','autumn','winter','spring'};
d = [31 28 31 30 31 30 31 31 30 31 30 31];
dd = cumsum(d');
b = [1;dd(cumsum([2 3 3 3 1]'))];
x = sort(randi(365,20,1)); % Let x is data as column 8 from your data
[~,ii] = histc(x,b);
ii(ii==5) = 1; % or ii = rem(ii-1,4)+1;
out = ssn(ii);
카테고리
도움말 센터 및 File Exchange에서 Data Type Identification에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!