Comparing Data sets with same numbers of Array

2 次查看(过去 30 天)
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
Cedric 2019-4-27
编辑:Cedric 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 个评论
Sophie Stringer
Sophie Stringer 2019-4-28
Thank you that is great!
Is there an easy way of pulling out the values where the wind is equal to 'SE-S', as the days I gave above were just made up. Or could I just say:
dayId = [1:92]
Would that identify all days out of the 92 days that are equal to SE-S?
Thanks for your help,
Cheers :D
Cedric
Cedric 2019-4-28
编辑:Cedric 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.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by