Clear Filters
Clear Filters

I am getting amplitude zero, But it is impossible

1 view (last 30 days)
I am getting a graph where amplitude is zero,How it possible?
I am attchimg here code which generate this graphs
clc;
M =8; %here we initialize the number of constellation point of qam
no_of_data_bits=1024;
Fm=10^6;%Max freq
block_size = 16; %Size of each OFDM block to add cyclic prefix
cp_len = floor(0.1 * block_size); %Length of the cyclic prefix
data_source= abs(round(randn(1,no_of_data_bits)));%here we take random normal function
figure(1);
x=1:no_of_data_bits;
stem (x*(1/Fm),data_source);
grid minor;
xlabel('time(Microsecond)','Fontsize',14);
ylabel('amplitude','Fontsize',14);
title('Transmitted Data','Fontsize',14);%here we plot that transmitted data
qam_modulated_data = qammod(data_source, M);%here we perform 8bit qam on the random normal function
nqdata = length(qam_modulated_data);
data = 0:M-1;
scatterplot(qam_modulated_data,1,0,'r*');
[udata, uidx] = unique(qam_modulated_data);
nudata = length(udata);
grid minor
for k=1:nudata
text(real(udata(k))-0.4,imag(udata(k))+0.4,num2str(data_source(uidx(k))));
end
axis([-4 4 -2 2])
qm = abs(qam_modulated_data);
figure(3);
stem(qm)
title('MODULATED TRANSMITTED DATA','Fontsize',14);%here we plot those constellation point
y=ifft(qam_modulated_data);
figure(4);
x=1:nqdata;
stem(x*Fm,abs(y));
grid minor;
xlabel('freq(Mhz)');
ylabel('amplitude of ifft');
title('without hermitian ifft','Fontsize',14);
I dont know why zero amplitude is coming,please help.
  1 Comment
Cris LaPierre
Cris LaPierre on 3 Mar 2021
One observation - you take the ifft of a time-domain signal, and label the x axis as frequency. Did you mean to take the fft instead?

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 3 Mar 2021
Not 0. The value in the first location is enough larger than the rest of the data, that the rest of the data appears close to the axes in comparison. Below I skip plotting the first point.
Remember that fft() and ifft() are close to being the same operation, so when you ifft() your time domain signal, that is close to being the same as doing fft() of the time domain signal. And, just like if you had done fft(), the first output bin will be the sum of the time domain signal, so if your time domain signal has a non-zero mean then the first output bin can end up being much higher in magnitude than the other outputs.
M =8; %here we initialize the number of constellation point of qam
no_of_data_bits=1024;
Fm=10^6;%Max freq
block_size = 16; %Size of each OFDM block to add cyclic prefix
cp_len = floor(0.1 * block_size); %Length of the cyclic prefix
data_source= abs(round(randn(1,no_of_data_bits)));%here we take random normal function
figure(1);
x=1:no_of_data_bits;
stem (x*(1/Fm),data_source);
grid minor;
xlabel('time(Microsecond)','Fontsize',14);
ylabel('amplitude','Fontsize',14);
title('Transmitted Data','Fontsize',14);%here we plot that transmitted data
qam_modulated_data = qammod(data_source, M);%here we perform 8bit qam on the random normal function
nqdata = length(qam_modulated_data);
data = 0:M-1;
scatterplot(qam_modulated_data,1,0,'r*');
[udata, uidx] = unique(qam_modulated_data);
nudata = length(udata);
grid minor
for k=1:nudata
text(real(udata(k))-0.4,imag(udata(k))+0.4,num2str(data_source(uidx(k))));
end
axis([-4 4 -2 2])
qm = abs(qam_modulated_data);
figure(3);
stem(qm)
title('MODULATED TRANSMITTED DATA','Fontsize',14);%here we plot those constellation point
y=ifft(qam_modulated_data);
figure(4);
x=1:nqdata;
stem(x(2:end)*Fm,abs(y(2:end)));
grid minor;
xlabel('freq(Mhz)');
ylabel('amplitude of ifft');
title('without hermitian ifft','Fontsize',14);
  2 Comments
Dipsikha Roy
Dipsikha Roy on 4 Mar 2021
Sir you are great,I have written code
A1=Append_prefix(:,1);
A2=Append_prefix(:,2);
A3=Append_prefix(:,3);
A4=Append_prefix(:,4);
A5=Append_prefix(:,5);
A6=Append_prefix(:,6);
A7=Append_prefix(:,7);
A8=Append_prefix(:,8);
figure(12), subplot(8,1,1),plot(real(A1),'r'),title('Cyclic prefix added to all the odd sub-carriers')
subplot(8,1,2),plot(real(A2),'y')
subplot(8,1,3),plot(real(A3),'b')
subplot(8,1,4),plot(real(A4),'g')
subplot(8,1,5),plot(real(A5),'m')
subplot(8,1,6),plot(real(A6),'k')
subplot(8,1,7),plot(real(A7),'c')
subplot(8,1,8),plot(real(A8),'g')
which gives me graph like
what I can write in the above code so that I can show in the graph that x axis is time and y axis is amplitude,
I have used x label and ylabel but the way it was showing time and amplitude i dont like it,Can you please suggest some better ways?
Dipsikha Roy
Dipsikha Roy on 24 Apr 2021
Hi walter roberson sir can you help me in plotting ber vs snr curve for received data of above code?

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!