![190715 134831-Figure 1.jpg](https://www.mathworks.com/matlabcentral/answers/uploaded_files/229900/190715%20134831-Figure%201.jpeg)
Correlation between two vectors
조회 수: 43 (최근 30일)
이전 댓글 표시
How to show the correlation between two vectors? I know I can use the function 'xcorr', but is there a function that shows graphically this correlation?
댓글 수: 0
채택된 답변
Adam Danz
2019년 7월 1일
편집: Adam Danz
2019년 7월 15일
n = 0:15;
x = 0.84.^n;
y = circshift(x,5);
[c,lags] = xcorr(x,y);
stem(lags,c)
xlabel('lag')
ylabel('r')
or more simply,
plot(lags, c, '-o')
![190715 134831-Figure 1.jpg](https://www.mathworks.com/matlabcentral/answers/uploaded_files/229900/190715%20134831-Figure%201.jpeg)
This shows a maximum correlation at lag -5 which makes sense since we circularly shifted the data by 5 units.
댓글 수: 0
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!