Spatial correlations with a timeseries

조회 수: 13 (최근 30일)
Kelly Kilbourne
Kelly Kilbourne 2021년 2월 17일
댓글: Kelly Kilbourne 2021년 2월 23일
Greetings,
I am trying to correlate a single time series to an xy field of timeseries. I have an array (local temperature data, a 1x 2005 dataset) and I want to correlate it to surface temperature over the globe (a 180x89x2005 dataset). I want a result that is a 180x89 matrix with each value representing the correlation coefficient between my local temperature and the temperature at that spot over the time period of interest (i.e. with each column and row over the third dimension). The problem I face is trying to make the dimensions work so that I can simply make the corr function work properly. This feels like a stupid problem; I think I am missing something simple.

답변 (1개)

Duncan Po
Duncan Po 2021년 2월 18일
corr works on columns in 2D matrices.
Your local temperature is a row, so you need to tranpose it:
local_temp = local_temp.';
Your surface temperature is a 3D array with each location a vector along the third dimension. You need to permute and then flatten to make it a matrix:
surface_temp = permute(surface_temp, [3 1 2]); % permute
surface_temp = surface_temp(:,:); % flatten
corr should then work:
[rho, pval] = corr(local_temp, surface_temp);
You may want to reshape the output.
  댓글 수: 1
Kelly Kilbourne
Kelly Kilbourne 2021년 2월 23일
Thank you! I had played with permute, but had not tried flattening the data and that was key. Now I just need to figure out how to reshape the output again so that I can plot it.

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

카테고리

Help CenterFile Exchange에서 Preprocessing Data에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by