Модуляция OFDM
Автор
function rectpuls(t, Tw)
y = (abs.(t).<Tw/2-eps());
y[abs.(t.-(-Tw/2)).<eps()] .= 1.0;
return y;
end
function helperPlotOFDM()
var_fft = EngeeFFT();
var_fftshift = EngeeFFTshift();
fs = 256; # sample rate in Hz
time = ([0:1/fs:(fs-1)/fs...] .- 0.5); # seconds
freq = [-fs/2:(fs/2)-1...]; # For plotting
timePlotIdx = [fs/4:(3*fs/4)-1...]; # Zoom in on the time plot
Rsym = 8; # Symbol rate in Hz
numSigs = 4;
pulse = zeros(ComplexF64,fs,numSigs);
color = [:yellow,:red,:green,:blue];
pulse[:,1] = rectpuls(time,1/Rsym) .*exp.(1im*2*pi*(1-1)*Rsym*time);#pulse[:,iSig] = rectpuls(time,1/Rsym) .*exp.(1im*2*pi*(iSig-1)*Rsym*time);
pulse[:,2] = rectpuls(time,1/Rsym) .*exp.(1im*2*pi*(2-1)*Rsym*time);
pulse[:,3] = rectpuls(time,1/Rsym) .*exp.(1im*2*pi*(3-1)*Rsym*time);
pulse[:,4] = rectpuls(time,1/Rsym) .*exp.(1im*2*pi*(4-1)*Rsym*time);
spectrumToPlot1 = EngeeDSP.step!(var_fftshift,abs.(EngeeDSP.step!(var_fft, pulse[:,1]))); #fftshift(abs.(fft(pulse[:,1])));
spectrumToPlot2 = EngeeDSP.step!(var_fftshift,abs.(EngeeDSP.step!(var_fft, pulse[:,2]))); #fftshift(abs.(fft(pulse[:,2])));
spectrumToPlot3 = EngeeDSP.step!(var_fftshift,abs.(EngeeDSP.step!(var_fft, pulse[:,3]))); #fftshift(abs.(fft(pulse[:,3])));
spectrumToPlot4 = EngeeDSP.step!(var_fftshift,abs.(EngeeDSP.step!(var_fft, pulse[:,4]))); #fftshift(abs.(fft(pulse[:,4])));
signal1 = plot(time[Int64.(timePlotIdx)],real.(pulse[Int64.(timePlotIdx),1]),linecolor = color[1], label = "Исходный импульс");#signal = plot!(time[Int64.(timePlotIdx)],real.(pulse[Int64.(timePlotIdx),iSig]),linecolor = color[iSig])
signal2 = plot!(time[Int64.(timePlotIdx)],real.(pulse[Int64.(timePlotIdx),2]),linecolor = color[2], label = "Импульс с центром на Rsym");
signal3 = plot!(time[Int64.(timePlotIdx)],real.(pulse[Int64.(timePlotIdx),3]),linecolor = color[3], label = "Импульс с центром на 2Rsym");
signal4 = plot!(time[Int64.(timePlotIdx)],real.(pulse[Int64.(timePlotIdx),4]),linecolor = color[4], label = "Импульс с центром на 3Rsym");
xlabel!("Время (сек)");
ylabel!("Амплитуда");
#plot!(legend=:outerbottom, legendcolumns=3);
xlims!(-0.25, 0.25);
ylims!(-1.1, 1.1);
# Spectra
spectr1 = plot(Int64.(freq),spectrumToPlot1,linecolor = color[1], label = "Исходный импульс");
spectr2 = plot!(Int64.(freq),spectrumToPlot2,linecolor = color[2],label = "Импульс с центром на Rsym");
spectr3 = plot!(Int64.(freq),spectrumToPlot3,linecolor = color[3],label = "Импульс с центром на 2Rsym");
spectr4 = plot!(Int64.(freq),spectrumToPlot4,linecolor = color[4],label = "Импульс с центром на 3Rsym");
xlabel!("Частота (Гц)");
ylabel!("Амплитуда");
xlims!(-30, 60)
xaxis = Plots.get_axis(Plots.get_subplot(spectr1,1),:x)
yaxis = Plots.get_axis(Plots.get_subplot(spectr1,1),:y)
xaxis[:gridalpha] = 0.8
yaxis[:gridalpha] = 0.8
xaxis[:foreground_color_grid] = colorant"white"
yaxis[:foreground_color_grid] = colorant"white"
display(signal1), display(spectr1);
end
#helperPlotOFDM()