📄 lagcor.m
字号:
function [lagcor] = lagcor(field, index, lag);% HEADER_START%% NAME: lagcor%% DESCRIPTION:%% Computes (lag) correlations between a field and a time series without NaNs%% REQUIRED_ARGS: %% field: 3D array time x lat x lon)% index: 1D array providing the time series to be correlated with field % lag: : positive number% %% OPTIONAL_ARGS: %% lag: +ve/-ve number. If > 0 then field lags index otherwise index lags% field. %% OUTPUT_ARGS: %% lagcor: lat x lon array containing the lagged correlations%% COMMENTS:%% No NaNs allowed%% USAGE:%% example: field = rand(10, 3, 5); index = rand(10,1); % cor = lagcor(field, index, 1);% % AUTHOR:% % F.Panagiotopoulos@rdg.ac.uk,% A.Hannachi@reading.ac.uk, July 2003.%% HISTORY: Sep 2004%% HEADER_END%siz = size(field);ti = siz(1); la = siz(2) ; lo = siz(3);field1=reshape(newfield, ti,la*lo); if (lag >= 0) dsip('fields lags index') newindex = index(lag+1:ti); newfield = field(1:ti-lag,:); else dsip('index lags field') lag = -lag; newindex = index(1:ti-lag); newfield = field(lag+1:ti,:); endlagcor = [];for k = 1:la*lo; x = field1(:,k); xx = corrcoef(x,newindex); lagcor(k) = xx(2);end lagcor = reshape(lagcor,la,lo);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -