wrong output in matlab coding

1 Ansicht (letzte 30 Tage)
ali hassan
ali hassan am 8 Dez. 2020
Bearbeitet: KSSV am 8 Dez. 2020
actually i have a simple code and what i am actually doing is that i am generating a signal and then i am delaying that signal and then i am correlating the signal but in the correlation plot i am getting the peak at zero. should the be at zero??
output:
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,5); %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);
t21 = finddelay(xs,x1)

Antworten (0)

Kategorien

Mehr zu Fourier Analysis and Filtering finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by