Comparing Data sets with same numbers of Array

조회 수: 1 (최근 30일)
Sophie Stringer . 2019년 4월 27일
편집: Cedric Wannaz . 2019년 4월 28일
Hi there,
I have 2 data sets which I would like to compare. Both data sets have 92 values (or 92 days of data).
My first Data set is categorial wind direction. My second data set is numerical values (carbon concentration).
I would like to be able to determine, for example, in the first data set where say day 1, 5, 10, 15, 50, 60, 92 had winds of N-NE, what are the corresponding values in the 2nd data set (carbon concentration).
And then make a mean of the carbon concentrations when winds were blowing N-NE.
I've attached my data,
Any help would be much appreciated!
Cheers :D

댓글을 달려면 로그인하십시오.

채택된 답변

Cedric Wannaz 2019년 4월 27일
편집: Cedric Wannaz 님. 2019년 4월 27일
As you have no N-NE direction, here is an example for SE-S:
dayId = [1, 5, 10, 15, 50, 60, 92] ;
cat_sub = cat_wind_direction(dayId) ;
s_cf_sub = s_cf_day(dayId) ;
mean_cf = mean( s_cf_sub(cat_sub == 'SE-S') )
Let me know if you have any question.
댓글 수: 2표시 이전 댓글 수: 1숨기기 이전 댓글 수: 1
Cedric Wannaz 2019년 4월 28일
편집: Cedric Wannaz 님. 2019년 4월 28일
In fact, it is simpler to get all days at a given direction than specific days. The following does it:
select = cat_wind_direction == 'SE-S' ;
mean_cf = mean( s_cf_day(select) ) ;
If you have a few minutes, look up "MATLAB logical indexing" on google and spend a minute reading about it.
Then look at select (execute whos in the command window and look at its size and class). You will see that it is a 92x1 vector of logicals that are the element-wise outcome of the test (relational operation): cat_wind_direction == 'SE-S'. Its elements are booleans/logicals (true/false, displayed as 1/0), and it can be use to index any 92x1 array of anything. We use it to index/extract all elements of s_cf_day for which select is true.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Time Series Events에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by