I tried to get power spectrum of ofdm passband signal. Below is the whole matlab code for that with BPSK+ofdm. and I got the power spectrum as below. I wonder that is that right form or not?
Nfft=64; % number of sub carriers
Ncp=Nfft/4; % number of cyclic prefix
Nuc=52; % number of used carriers
d=2*(randn(1,Nuc)>0.5)-1; % bpsk mapped data
X=zeros(1,Nfft);
X([2:Nuc/2+1,(end-Nuc/2)+1:end])=d; % only used sub carrier
x=ifft(X,Nfft); % time domain
sbb=[x(end-Ncp+1:end) x]; % to add cyclic prefix
%% passband
fc=4; % carrier frequency
sps=16; % samples per symbol
Tsym=1; % symbol duration time
Ts=Tsym/sps; % sampling time
fs=1/Ts;
Tmax=(Nfft+Ncp)*sps*Ts-Ts;
t=0:Ts:Tmax;
%return
% I-ch up-sampling
I=real(sbb);
I=repmat(I,sps,1);
I=I(:).';
sI=I.*cos(2*pi*fc*t);
% Q-ch up-sampling
Q=imag(sbb);
Q=repmat(Q,sps,1);
Q=Q(:).';
sQ=Q.*-sin(2*pi*fc*t);
s=sI+sQ; % transimt signal
%% plot power spectrum
f=(0:(numel(s)-1))/numel(s)*fs;
figure
plot(f,10*log10(abs(fft(s))))
%plot(f/1e6,10*log10(abs(fft(s))))
xlabel('frequency[Hz]');
ylim([-40 20]);
title('full span');
grid on
figure
plot(f,10*log10(abs(fft(s))))
%plot(f/1e6,10*log10(abs(fft(s))))
xlabel('frequency[Hz]');
ylim([-40 20]);
xlim([3 5])
title('main band');
grid on