i have N observations z(1),z(2),...z(N) how can do the following formula , where N=50

 採用された回答

Andrei Bobrov
Andrei Bobrov 2017 年 5 月 25 日
編集済み: Andrei Bobrov 2017 年 5 月 25 日
[EDIT]
MATLAB >= R2016b
N = numel(Z);
a = triu(toeplitz(Z));
a = [a,a(:,end-1:-1:1)]./exp((1-N:N-1)*20);
K = Z(end)*sum(a(:))/(2*N);
MATLAB <= R2016a
N = numel(Z);
a = triu(toeplitz(Z));
a = bsxfun(@rdivide,[a,a(:,end-1:-1:1)],exp((1-N:N-1)*20));
K0 = Z(end)*sum(a(:))/(2*N);
with loop for..end
N = numel(Z);
K = 0;
for ii = 1-N:N-1
for jj = 1:N-abs(ii)
K = K + Z(jj)*Z(jj+abs(ii))*exp(-20*ii);
end
end
K = K/2/N;

3 件のコメント

mohammed hamdy
mohammed hamdy 2017 年 5 月 25 日
An error appears
mohammed hamdy
mohammed hamdy 2017 年 5 月 25 日
thank u very much
Andrei Bobrov
Andrei Bobrov 2017 年 5 月 25 日
You use old version of MATLAB. I'm added variant for MATLAB <= R2016a

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by