Comparing Data sets with same numbers of Array
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
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
0 Commenti
Risposta accettata
Cedric
il 27 Apr 2019
Modificato: Cedric
il 27 Apr 2019
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 Commenti
Cedric
il 28 Apr 2019
Modificato: Cedric
il 28 Apr 2019
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.
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Logical in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!