xcorr function doesnt change its max. even i delayed the signal

1 回表示 (過去 30 日間)
badr
badr 2013 年 10 月 12 日
回答済み: badr 2013 年 10 月 12 日
Hi, Iam trying to do some stuff about calculating the delay between two signals by using the difference between the two max.'s of the correlation functions that will be calculated so, i wrote a small code:
>> a=[ones(1,5),zeros(1,5),ones(1,5),zeros(1,5),ones(1,5),zeros(1,5)]; >> plot(a); >> plot(b); >> b=[zeros(1,26),ones(1,5),zeros(1,5),ones(1,5),zeros(1,5),ones(1,5),zeros(1,5)]; >> plot(b); >> c=[zeros(1,30),ones(1,5),zeros(1,5),ones(1,5),zeros(1,5),ones(1,5),zeros(1,5)]; >> plot(c); >> plot(xcorr(a,c)); >> plot(xcorr(a,b));
now xcorr(a,c) is the same of xcorr(a,b) despite of the predicted result of xcorr(a,c) is that it will be shifted by 3 from xcorr(a,b
PLZ, can any one help me in this ?
THNX for reading.
  1 件のコメント
Matt J
Matt J 2013 年 10 月 12 日
Please apply the
formatting button to your code to make it readable.

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

回答 (2 件)

badr
badr 2013 年 10 月 12 日
if true
>> a=[ones(1,5),zeros(1,5),ones(1,5),zeros(1,5),ones(1,5),zeros(1,5)]; >> plot(a); >> plot(b); >> b=[zeros(1,26),ones(1,5),zeros(1,5),ones(1,5),zeros(1,5),ones(1,5),zeros(1,5)]; >> plot(b); >> c=[zeros(1,30),ones(1,5),zeros(1,5),ones(1,5),zeros(1,5),ones(1,5),zeros(1,5)]; >> plot(c); >> plot(xcorr(a,c)); >> plot(xcorr(a,b));
end
sorry for that
  1 件のコメント
Image Analyst
Image Analyst 2013 年 10 月 12 日
You'd get more enthusiastic help if you made it easier for us, like don't have the if true stuff in there (you probably clicked {}Code before you pasted in the code instead of afterwards), and don't have >> and make it just commands like we can copy and paste into an m-file script.

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


badr
badr 2013 年 10 月 12 日
sorry i attached the .m file

カテゴリ

Help Center および File ExchangeCorrelation and Convolution についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by