How to do correlation from data with series
1 view (last 30 days)
Show older comments
Hi i have to make corelation to check the dependance of variable c from series 1 or 2. Can I split t vector into two one t1 and t2 make 2 seperet correlations of t1 to c1 and t2 to c2?
t=[21,22 ,323,43,231,53,23,12,53,12]
c=[23,12 ,223,333,21,63,24,23,763,14]
p={"1","1","1","1","1","2","2","2","2","2"}
1 Comment
Accepted Answer
Adam Danz
on 14 Jan 2021
Edited: Adam Danz
on 15 Jan 2021
You can use xcorr and indexing.
t=[21,22 ,323,43,231,53,23,12,53,12];
c=[23,12 ,223,333,21,63,24,23,763,14];
p=["1","1","1","1","1","2","2","2","2","2"]; % <-- String array with square brackets
[groupID, groups] = findgroups(p)
xcorr(c(groupID==1), t(groupID==1))
xcorr(c(groupID==2), t(groupID==2))
or use splitapply
splitapply(@(x1,x2){xcorr(x1,x2)}, c, t, groupID)
0 Comments
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!