Skip to content

Commit 20617fc

Browse files
Update sw_radio.m
1 parent 5857d3f commit 20617fc

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

sw_radio.m

+29
Original file line numberDiff line numberDiff line change
@@ -187,3 +187,32 @@
187187
xlabel('tau');
188188
ylabel('R(tau)');
189189

190+
%%Bandwidth
191+
L = 1400; % Length of signal
192+
n = 2^nextpow2(L);
193+
T = 0.01; % Sampling period
194+
Fs = 1/T; % Sampling frequency
195+
196+
t = (0:L-1)*T; % Time vector
197+
198+
%Compute the Fourier transform of the signal.
199+
PSD = fft(R_tau,n);
200+
PSD = fftshift(PSD);
201+
202+
% f = Fs*(0:(L/2))/L;
203+
f = Fs * (-n/2:n/2-1)/n;
204+
205+
%Compute the two-sided spectrum P2
206+
P2 = abs(PSD/n).^2;
207+
% P1 = P2(1:L/2+1);
208+
% P1(2:end-1) = 2*P1(2:end-1);
209+
210+
Smoothed_PSD = smooth(P2); %Smooth the curve from the noise, to be plotted
211+
figure (4)
212+
subplot(1,1,1,'LineWidth',5)
213+
plot(f,Smoothed_PSD)
214+
title("PSD")
215+
xlabel("f (Hz)")
216+
ylabel("S(f)")
217+
218+

0 commit comments

Comments
 (0)