# Comparing Data sets with same numbers of Array

조회 수: 6(최근 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
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.

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

### Community Treasure Hunt

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

Start Hunting!
{"ft_lang_label":"__label__en","ft_lang_prob":0.8386205,"math_prob":0.81899136,"size":1962,"snap":"2022-40-2023-06","text_gpt3_token_len":649,"char_repetition_ratio":0.10674157,"word_repetition_ratio":0.04519774,"special_character_ratio":0.29510704,"punctuation_ratio":0.12801932,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9507182,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2022-10-01T02:03:35Z\",\"WARC-Record-ID\":\"<urn:uuid:412e94c2-7866-47ee-ad30-02991a26b85a>\",\"Content-Length\":\"134147\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:66a2a757-cf79-4e90-96bd-d4bf507c9d34>\",\"WARC-Concurrent-To\":\"<urn:uuid:db9112a2-8cbd-4fe8-8a47-18d63762ff5c>\",\"WARC-IP-Address\":\"23.34.160.82\",\"WARC-Target-URI\":\"https://kr.mathworks.com/matlabcentral/answers/458857-comparing-data-sets-with-same-numbers-of-array\",\"WARC-Payload-Digest\":\"sha1:APXNZXZMGAPUOLFOOU7N5FNX4KRPTSX7\",\"WARC-Block-Digest\":\"sha1:2XLNFU4JRSXKQQ65HVU6NZP7ZJ3GYFVI\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2022/CC-MAIN-2022-40/CC-MAIN-2022-40_segments_1664030335514.65_warc_CC-MAIN-20221001003954-20221001033954-00282.warc.gz\"}"}