相互相関xcorrについて質問です
Show older comments
相互相関xcorrについて質問です。(素人ですみません)
以下のプログラムを実行したところ、変数lagsに0が入ります。
プログラムとしては、エクセルから読み込み、変数(d1,d2)に入れ込んで相互相関を取っています。
(d2はd1からcircshiftを使って中身を100だけ動かしているのでラグは100になると思うのですが、、)
分かる方がいらっしゃれば、ご教授お願い致します。
%データ入力
data = importdata('data.xlsx');
size(data(:,1));
datasize = ans(1);
t = 1:datasize;
d1 = data(:,1);
d2 = circshift(d1,-100)
%相互相関
[c,lags] = xcorr(d1,d2,'normalized');
stem(lags,c);
saveas(gcf,'LagData.png');
1 Comment
Naoya
on 21 Jan 2020
xcorrに入力する実際のデータがないと判断できませんが、例えば、 xcorr に入力する信号の長さが 100 サンプルだったり、正弦波のように元々周期的な信号が対象の場合は、ラグが 0 となる可能性もあります。
また、circshift (循環シフト)ではなく、
d2 = zeros( size(d1));
d2(1:end-100) = d(101:end);
のような形で与えることで結果が変わってくることもあるかもしれません。
Accepted Answer
More Answers (1)
Takaaki Takatsuki
on 21 Jan 2020
0 votes
Categories
Find more on 相関と畳み込み in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!