I am new in matlab so maybe my question is stupid. I have a two signals rec(t) and sent(t) for which I want to find time delay through phase vs. frequency realtionship obtained from cross spectrum. I obtained cross spectrum through the FFT of the cross corelation between rec(t) and sent(t). Here it is:
time=data(15:length(data),1); %time of measurement - s
sent=data(15:length(data),2); %sent signal - mV
rec=data(15:length(data),3); %recorded signal - mV
samples=length(time); %number of samples
Fs=samples/max(time); %sampling frequency - Hz
dt=max(time)/samples; %time interval - s
freq=(0:samples/2)/samples/dt; %frequency scale for FFT
FFTrec=fft(rec); %FFT of recorded signal
FFTsent=fft(sent); %FFT of sent signal
CorrRecSent=(ifft(FFTrec.*conj(FFTsent))); %cross correlation definition
CS=fft(CorrRecSent); %cross spectrum (CS)
amp=abs(CS); %amplitude of CS
amp1=amp(1:samples/2+1); %amplitude of CS for half of the frequency spectrum
A2=angle(CS);
A1=A2(1:samples/2+1); %phase angle of (CS)
A=unwrap(A1); %unwrapped phase
plot(freq,(A));
xlabel('frequency (Hz)')
ylabel('phase (rad)')
And here is the plot. Is there any command or procedure how can I obtain exact phase angles for given frequencies (marked with black line)? Or how can I find the slope of the drawn orange line? I chose this range of frequencies because my sent signal was 5 kHz, so something around was chosen.
Thanks for help.