フィルターのクリア

spectrogram os sent and received signal

1 回表示 (過去 30 日間)
khaled shalabi
khaled shalabi 2019 年 7 月 26 日
Hello
i tried to estimate the range of target by using fft
i had a problem in plot the spectrogram of sent and receives signal which should have the same spectrom but the defference is in delay, but i got always different specrom as you see in figure 5
how can solve this problem ?
how can fill zeros in front of received signal ?
the right way is that the sent and received should start from the same frequency but the received has time delays.PNG
clc;
close all;
clear all;
%% parameters
fs = 100e3; % sampling frequency
fc = 20e3; % carrier frequency
Ts = 1/fs; % sampling period
BW = 10e3; % bandwidth
T = 50e-3; % period
c = 340; % speed of sound in air
N = T/Ts; %N is uded for the length of FFT
ff = linspace(-fs/2,fs/2,2*N); %frequency vector of FFT
numRep = 50; % to get contiues wave we want to repaeate the chirp 50 times
%% Tx Signal
tu = 0:Ts:T-Ts; %time range of the upsweep
td = T:-Ts:0; %time range of the downsweep
tt = [tu td]; %time range of the chirp
% generate Tx signal
TxSig = cos((2*pi*(fc-BW/2)*tt)+(pi*BW*(tt.^2)/T)); %transmitted signal
TxSig = TxSig + randn(size(TxSig));
RepTxSig = repmat(TxSig,[1,numRep]); %repeat the transmitted signal 50 times to get FMCW wave
% plot Tx signal in time domain
figure();
plot(tt,TxSig); %plot the transmitted signal
grid on;
title('Transmitted Signal')
xlabel('Time (Seconds)'); ylabel('Amplitude');
% plot spectrogram for Tx signal
figure();
[St,Ft,t,Pt] = spectrogram(RepTxSig,256,128,256,fs); %to get the relation between the time with frequency and power density.
surf(t,Ft,10*log10(Pt),'edgecolor','none'); axis tight; %to get the graph 3D
view(0,90); %to get the top projection of 3D grath
title('Spectrogram for Tx Signal')
xlabel('Time (Seconds)'); ylabel('freq. (Hz)');
% plot Tx signal in freq. domain
fftTx = fftshift(fft(RepTxSig,2*N));
fftTxdb = 20*log10(abs(fftTx));
figure();
plot(ff,fftTxdb-max(fftTxdb))
axis tight;
grid on;
title('FFT of Transmitted Signal')
xlabel('freq. (Hz)'); ylabel('Amplitude (dB)');
%% Rx Signal with target range and delay
R = 3.5;
to = 2*R/c;
% offset
K = to/Ts;
tu = (K*Ts)-to:Ts:T-Ts;
td = T:-Ts:0;
tr = [tu td];
% generate Rx signal
RxSig = cos((2*pi*(fc-BW/2)*(tr-to))+(pi*BW*((tr-to).^2)/T));
figure();
plot(tr,RxSig);
grid on;
title('Received Signal')
xlabel('Time (Seconds)'); ylabel('Amplitude');
% plot spectrogram for Tx signal and Rx signal
figure();
[Sr,Fr,t,Pr] = spectrogram(RepRxSig,256,128,256,fs);
surf(t,Fr,10*log10(Pr),'edgecolor','none'); axis tight;
view(0,90);
title('Spectrogram for Tx Signal and Rx Signal')
xlabel('Time (Seconds)'); ylabel('Hz');
caxis([-60 -30])
colorbar
hold on
[St,Ft,t,Pt] = spectrogram(RepTxSig,256,128,256,fs);
surf(t,Ft,10*log10(Pt),'edgecolor','none');
% plot Rx signal in freq. domain
fftRx = fftshift(fft(RepRxSig,2*N));
fftRxdb = 20*log10(abs(fftRx));
figure();
plot(ff,fftRxdb-max(fftRxdb))
axis tight;
grid on;
title('FFT of Received Signal')
xlabel('freq. (Hz)'); ylabel('Amplitude (dB)');
%% Mixing
MixSig = RepTxSig.*RepRxSig;
figure();
plot(MixSig);
grid on;
title('Mixed Signal')
%% Range detection
Y = fftshift(fft(MixSig,2*N));
Ydb = 20*log10(abs(Y));
figure;
plot(ff,Ydb-max(Ydb))
axis tight;
grid on;
title('FFT of Mixed Signal')
xlabel('freq. (Hz)'); ylabel('Amplitude (dB)');
ind=find(Ydb(N+1:2*N)==max(Ydb(N+1:2*N)));
f1=ff(N+ind);
ind=find(Ydb(1:N)==max(Ydb(1:N)));
f2=-ff(ind);
fb=(f1+f2)/2; % estimating shift frequency
estR = c*fb*T/(2*BW) % estimated range of the target
%% end
spectro.png

回答 (0 件)

カテゴリ

Help Center および File ExchangeSpectral Estimation についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by