フィルターのクリア

correlation of 2 signals

3 ビュー (過去 30 日間)
ali hassan
ali hassan 2020 年 11 月 28 日
コメント済み: Image Analyst 2020 年 11 月 28 日
Actually I am corelating two signals but my question is that in graph the correlation should be between -1 and 1 but it is not like that code:
t=linspace(0,1000,100001) %in ms xs=randn(1,100001)
grid on
subplot(3,1,1) plot(t,xs) title('SIGNAL RECEIVED AT MASTER')
shift_ms = 10; %SIGNAL RECEIVED AT RECEIVER 1(TIME DELAYING THE DISCRETE SIGNAL) x1=circshift(xs,shift_ms*.1); %signal received at receiver 1
% subplot(3,1,2) plot(t,x1) title('SIGNAL RECEIVED AT RECEIVER#1')
[c,lags]=xcorr(xs,x1);
subplot(3,1,3)
plot(lags,c)
title('CORRELATION OF RECEIVER 1 AND PROCESSING UNIT')
[maxval indx]=max(c) %[xMax,idx] = max(x) returns two outputs.first is max value of x and second is max index value maxval
shiftCalc_ms = (length(t)-indx)/10
t21 = finddelay(xs,x1)

回答 (1 件)

KALYAN ACHARJYA
KALYAN ACHARJYA 2020 年 11 月 28 日
編集済み: KALYAN ACHARJYA 2020 年 11 月 28 日
clc; clear;close all;
%%
t=linspace(0,1000,100001); %in ms
xs=randn(1,100001);
subplot(3,1,1),plot(t,xs);
title('SIGNAL RECEIVED AT MASTER')
shift_ms = 10; %SIGNAL RECEIVED AT RECEIVER 1(TIME DELAYING THE DISCRETE SIGNAL)
x1=circshift(xs,shift_ms*.1); %signal received at receiver 1
subplot(3,1,2)
plot(t,x1),title('SIGNAL RECEIVED AT RECEIVER#1')
[c,lags]=xcorr(xs,x1);
subplot(3,1,3),plot(c,lags)
title('CORRELATION OF RECEIVER 1 AND PROCESSING UNIT')
[maxval,indx]=max(c);
[xMax,idx] = max(xs);
shiftCalc_ms=(length(t)-indx)/10;
t21=finddelay(xs,x1);
  2 件のコメント
ali hassan
ali hassan 2020 年 11 月 28 日
https://www.mathworks.com/matlabcentral/answers/666543-correlation-of-2-signals#answer_558383 thankyou sir for your kind help. but now the graph is between 10^5 and 10^-5
Image Analyst
Image Analyst 2020 年 11 月 28 日
The correlation is the sum of the products of the overlapped elements, so there is no guarantee that that sum will be between 0 and 1. If you want it to be in that range, then you must call rescale():
scaledSignal = rescale(signal, 0, 1);

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

カテゴリ

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