how to make an array with the constellation point of qam

10 views (last 30 days)
qam_modulated_data = qammod(data_source, M); %where =8
now output will be points. How to insert those point in a array ?
please help me by writing the proper code,

Accepted Answer

Dipsikha Roy
Dipsikha Roy on 14 Dec 2020
how to show axis in megahertz  range?

More Answers (6)

Walter Roberson
Walter Roberson on 28 Nov 2020
qam_modulated_data is already an array.
Perhaps you mean
scatter(real(qam_modulated_data), imag(qam_modulated_data))
  14 Comments
Dipsikha Roy
Dipsikha Roy on 1 Dec 2020
Edited: Walter Roberson on 14 Dec 2020
sir i used this code
M=8
qam_modulated_data = qammod(data_source, M); // it will generate 8 constallention point.so i got 8 input
scatterplot(qam_modulated_data);title('MODULATED TRANSMITTED DATA');// i m plotting
qam_modulated_data(1:4)=-qam_modulated_data(5:8)
here out of that 8 input i m taking 4 input that is
1,2,3,4 th constallation point and then by putting a
minus sign in front of them i m trying to find out
5,6,7 8th element.so that my 5 to 8 th element
should be minus of my 4 input,my total output should
8,but after executing this code i m getting 10 output.
sir please can u help.
Dipsikha Roy
Dipsikha Roy on 1 Dec 2020
Edited: Dipsikha Roy on 1 Dec 2020
That 8 constallation point i want to arrange like suppose constallation pt means c
then c1,c2,c3,c4,-c1,-c2,-c3,c4 please help sir.

Sign in to comment.


Dipsikha Roy
Dipsikha Roy on 5 Dec 2020
Hi,
clear all
clc
close
M =8; %here we initialize the number of constallation point of qam
no_of_data_points = 128;
data_source= abs(round(randn(1,10)));%here we take random normal function
stem(data_source);
grid on;
xlabel('Data Points');
ylabel('transmitted data phase representation');
title('Transmitted Data') %here we plot that transmitted data
qam_modulated_data = qammod(data_source, M); %here we perform 8bit qam on the random normal function
scatterplot(qam_modulated_data);
title('MODULATED TRANSMITTED DATA'); %here we plot those constallation point
qam_modulated_data1(1:(M/2))=qam_modulated_data(1:(M/2)) %here we introduce another array named qam_modulated_data1 where first four element is first four constallation point
qam_modulated_data1(((M/2)+1):M)=-qam_modulated_data(1:(M/2))% in my qam_modulated_data1 array last four point is hermitian of first four point
y=fft(qam_modulated_data1) %here we apply fast fourier transform on the data of qam_modulated_data1 array
stem(y) %here we plot that fft result
xlabel('frequency');
ylabel('amplitude')
grid on;
title('odd frequency suppressed output')
Walter sir with your help I m able to do this much.But when I run this programme I get transmitted data graph and odd freq suppressed graph but not the scatterplot.Please help me.
  3 Comments
Dipsikha Roy
Dipsikha Roy on 5 Dec 2020
clc
close
M =8; %here we initialize the number of constellation point of qam
no_of_data_points = 128;
data_source= abs(round(randn(1,10)));%here we take random normal function
figure(1)
stem(data_source);
grid on;
xlabel('Data Points');
ylabel('transmitted data phase representation');
title('Transmitted Data') %here we plot that transmitted data
qam_modulated_data = qammod(data_source, M) %here we perform 8bit qam on the random normal function
scatterplot(qam_modulated_data)
title('MODULATED TRANSMITTED DATA')%here we plot those constellation point
qam_modulated_data1(1:(M/2))=qam_modulated_data(1:(M/2)); %here we introduce another array named qam_modulated_data1 where first four element is first four constellation point
qam_modulated_data1(((M/2)+1):M)=-qam_modulated_data(1:(M/2));% in my qam_modulated_data1 array last four point is Hermitian of first four point
y=fft(qam_modulated_data1); %here we apply fast Fourier transform on the data of qam_modulated_data1 array
figure(3)
stem(y); %here we plot that fft result
grid on;
xlabel('frequency');
ylabel('amplitude');
title('odd frequency suppressed output');
yc=conj(y);
real_y=y.*yc ;
figure(4)
stem(real_y);
grid on;
xlabel('frequency');
ylabel('amplitude of real values of fft');
title('real value of fft');
sir how to get 4 plot distinguisly?
Walter Roberson
Walter Roberson on 15 Dec 2020
"sir how to get 4 plot distinguisly?"
I do not understand the question? You are creating four different figures, and none of the plots looks the same as each other, so as far as I can see they are already distinguishable ?
You could use subplot() or tiledlayout() if you wanted.

Sign in to comment.


Dipsikha Roy
Dipsikha Roy on 14 Dec 2020
walter sir i want to plot above graph but frequency axis should be in mehahertz.which kind of changes in code should be done?please help..
  18 Comments
Dipsikha Roy
Dipsikha Roy on 26 Jan 2021
Edited: Dipsikha Roy on 26 Jan 2021
clc
close
M =8; %here we initialize the number of constellation point of qam
no_of_data_points = 1024;
Fm=10^6;%Max freq
data_source= abs(round(randn(1,8)));%here we take random normal function
figure(1);
x=1:M;
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
data = 0:M-1;
scatterplot(qam_modulated_data,1,0,'r*');
grid minor
for k=1:M
text(real(qam_modulated_data(k))-0.4,imag(qam_modulated_data(k))+0.4,num2str(data(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:M;
stem(x*Fm,abs(y));
grid minor;
xlabel('freq(Mhz)');
ylabel('amplitude of ifft');
title('without hermitian ifft','Fontsize',14);
qam_modulated_data1(1:(M/2))=qam_modulated_data(1:(M/2)); %here we introduce another array named qam_modulated_data1 where first four element is first four constellation point
qam_modulated_data1(((M/2)+1):M)=qam_modulated_data(1:(M/2));% in my qam_modulated_data1 array last four point is Hermitian of first four point
figure(5);
x=1:M;
stem (x*Fm,abs(qam_modulated_data1));
grid minor;
xlabel('frequency(MHZ)','Fontsize',14);
ylabel('amplitude','Fontsize',14);
title('Hermitian symmetry','Fontsize',14);
y1=ifft(qam_modulated_data1); %here we apply fast Fourier transform on the data of qam_modulated_data1 array
figure(6);
x=1:M;
stem(x*Fm,abs(y1)); %here we plot that ifft result
grid minor;
xlabel('Freq(Mhz)','Fontsize',14);
ylabel('amplitude','Fontsize',14);
title('even frequency suppressed output','Fontsize',14);
y1c=conj(y1);
real_y1=y1.*y1c ;
figure(7);
x=1:M;
stem(x*Fm,real_y1);
grid on;
xlabel('Freq(Mhz)','Fontsize',14);
ylabel('amplitude of real values of ifft','Fontsize',14);
title('real value of ifft','Fontsize',14);
##
z=fft(y1);
figure(8);
x=1:M;
stem(x*Fm,abs(z)); %here we plot that fft result
grid minor;
xlabel('frequency(MHZ)','Fontsize',14);
ylabel('amplitude','Fontsize',14);
title('fft output','Fontsize',14);
qam_modulated_data2(1:(M/2))=z(1:(M/2));
qam_modulated_data2(((M/2)+1):M)=qam_modulated_data(((M/2)+1):M);
figure(9);
x=1:M;
stem(x*Fm,abs(qam_modulated_data2));
xlabel('frequency(MHZ)','Fontsize',14);
ylabel('amplitude','Fontsize',14);
title('reverse Hermitian symmetry','Fontsize',14);
receieved_data=qamdemod(qam_modulated_data2,M);
figure(10)
x=1:M;
stem(x*(1/Fm),receieved_data); %here we plot that fft result
grid minor;
xlabel('time(Microsec)','Fontsize',14);
ylabel('amplitude','Fontsize',14);
title('received data','Fontsize',14);
here after ifft(In the ## place) i want to perform cyclic prefix then transmit in receiver section removing cyclic prefix and then recover signal.How can i do that?
Walter Roberson
Walter Roberson on 26 Jan 2021
You cannot do that in that program.
However if you were to read my earlier comments and compare the version of code I posted to your earlier code, you would be in a better position to modify your program to make it possible to do what you want.

Sign in to comment.


Dipsikha Roy
Dipsikha Roy on 31 Jan 2021
as per ur code that u gave me i got error like
Index in position 1
exceeds array bounds
(must not exceed 8).
Error in Untitled2
(line 74)
cyclic_prefix(j,i) =
ifft_Subcarrier(j+cp_start,i);
what can be done to make it correct?
  4 Comments
Walter Roberson
Walter Roberson on 31 Jan 2021
then took an array of 8 bit lenght where first 4 point are same as first four point of qam constallation point and last 4 bit also same
Why did you do that? You throw all of the results of that related code away without using it except to plot. The code reads more like you are required to demonstrate that 8-QAM has a particular relationship between the basic symbols. It does not read like you are calculating anything about your 8-QAM encoded input signal. You are not, for example, removing even frequencies of the 8-QAM version of the input signal, and using that as part of the information you build up into ODFM blocks that you might then apply cyclic prefixes to.
Dipsikha Roy
Dipsikha Roy on 31 Jan 2021
Edited: Dipsikha Roy on 31 Jan 2021
it is project of clipped ofdm, I want to supress even freq so that my ofdm efficiency increased,that clipped ofdm means even freq clipped ofdm should be added with cyclic prefix just to avoid inter block interference,
if i do "then took an array of 8 bit lenght where first 4 point are same as first four point of qam constallation point and last 4 bit also same" and then perform IFFT on that array then even frequency will be suppressed,that is main key of my project.

Sign in to comment.


Dipsikha Roy
Dipsikha Roy on 9 Feb 2021
Edited: Dipsikha Roy on 9 Feb 2021
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);
data1 = udata;
udata1(1:(M/2))=qam_modulated_data(1:(M/2)); %here we introduce another array named qam_modulated_data1 where first four element is first four constellation point
udata1(((M/2)+1):M)=qam_modulated_data(1:(M/2));% in my qam_modulated_data1 array last four point is Hermitian of first four point
figure(5);
x=1:M;
stem (x*Fm,abs(udata1));
grid minor;
xlabel('frequency(MHZ)','Fontsize',14);
ylabel('amplitude','Fontsize',14);
title('Hermitian symmetry','Fontsize',14);
y1=ifft(udata1); %here we apply fast Fourier transform on the data of udata1
figure(6);
x=1:M;
stem(x*Fm,abs(y1)); %here we plot that fft result
grid minor;
xlabel('Freq(Mhz)','Fontsize',14);
ylabel('amplitude','Fontsize',14);
title('even frequency suppressed output','Fontsize',14);
y1c=conj(y1);
real_y1=y1.*y1c ;
figure(7);
x=1:M;
stem(x*Fm,real_y1);
grid on;
xlabel('Freq(Mhz)','Fontsize',14);
ylabel('amplitude of real values of ifft','Fontsize',14);
title('real value of ifft','Fontsize',14);
number_of_subcarriers=M;
assert(number_of_subcarriers <= M);
cp_start=block_size-cp_len;
for i=1:number_of_subcarriers,
S2P = reshape(qam_modulated_data, no_of_data_bits/M,M);
size(S2P)
ifft_Subcarrier(:,i) = ifft((S2P(:,i)),16);% 16 is the ifft point
size(ifft_Subcarrier)
for j=1:cp_len,
cyclic_prefix(j,i) = ifft_Subcarrier(j+cp_start,i);
end
Append_prefix(:,i) = vertcat( cyclic_prefix(:,i), ifft_Subcarrier(:,i))
% Appends prefix to each subcarriers
end
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 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')
figure(11),plot((real(A1)),'r'),title('Orthogonality'),hold on ,plot((real(A2)),'c'),hold on ,
plot((real(A3)),'b'),hold on ,plot((real(A4)),'g'),hold on ,plot((real(A5)),'r'),hold on,plot((real(A6)),'b'),hold on,plot((real(A7)),'c'),hold on,plot((real(A8)),'g'),hold on,grid on
%Convert to serial from parallel
[rows_Append_prefix cols_Append_prefix]=size(Append_prefix)
len_ofdm_data = rows_Append_prefix*cols_Append_prefix
% OFDM signal to be transmitted
ofdm_signal = reshape(Append_prefix, 1, len_ofdm_data);
figure(13),
plot(real(ofdm_signal)); xlabel('Time'); ylabel('Amplitude');
title('OFDM Signal');grid on;
%Serial stream passing through the channel
channel = randn(1,2) + sqrt(-1)*randn(1,2);
after_channel = filter(channel, 1, ofdm_signal);
awgn_noise = awgn(zeros(1,length(after_channel)),0);
recvd_signal = awgn_noise+after_channel; % With AWGN noise
%Converts from serial back to parallel
figure(14),
plot(real(recvd_signal)),xlabel('Time'); ylabel('Amplitude');
title('OFDM Signal after passing through channel');grid on;
recvd_signal_paralleled = reshape(recvd_signal,rows_Append_prefix, cols_Append_prefix);
%now that the signal has passed through the channel we begin to work
%backawards, but we are first going to remove the CP
% Remove cyclic Prefix
%Now that the signal has already passed through the channel, we can get rid
%of the CP
recvd_signal_paralleled(1:cp_len,:)=[];
R1=recvd_signal_paralleled(:,1);
R2=recvd_signal_paralleled(:,2);
R3=recvd_signal_paralleled(:,3);
R4=recvd_signal_paralleled(:,4);
R5=recvd_signal_paralleled(:,5);
R6=recvd_signal_paralleled(:,6);
R7=recvd_signal_paralleled(:,7);
R8=recvd_signal_paralleled(:,8);
figure(15),plot((imag(R1)),'r'),subplot(8,1,1),plot(real(R1),'r'),
title('Cyclic prefix removed from the eight sub-carriers')
subplot(8,1,2),plot(real(R2),'y')
subplot(8,1,3),plot(real(R3),'g')
subplot(8,1,4),plot(real(R4),'b')
subplot(8,1,5),plot(real(R5),'k')
subplot(8,1,6),plot(real(R6),'c')
subplot(8,1,7),plot(real(R7),'m')
subplot(8,1,8),plot(real(R8),'b')
% Fourier Transofrm of the recievied signal
%Similarly to how we took the IFFT of the original signal, as we are back
%tracking we are now taking the FFT
for i=1:number_of_subcarriers,
fft_data(:,i) = fft(recvd_signal_paralleled(:,i),16);
end
F1=fft_data(:,1);
F2=fft_data(:,2);
F3=fft_data(:,3);
F4=fft_data(:,4);
F5=fft_data(:,5);
F6=fft_data(:,6);
F7=fft_data(:,7);
F8=fft_data(:,8);
figure(16), subplot(8,1,1),plot(real(F1),'r'),title('Fourier Transform of all the eight sub-carriers')
subplot(8,1,2),plot(real(F2),'y')
subplot(8,1,3),plot(real(F3),'g')
subplot(8,1,4),plot(real(F4),'b')
subplot(8,1,5),plot(real(F5),'K')
subplot(8,1,6),plot(real(F6),'c')
subplot(8,1,7),plot(real(F7),'m')
subplot(8,1,8),plot(real(F8),'g')
% Conversion to serial and demodulation
%The orignal data was in series, so we are taking the demodulated data
%which is still in parallel form and we are converting back into series to
%hopefully show the same data
recvd_serial_data = reshape(fft_data, 1,(16*8));
qam_demodulated_data = qamdemod(recvd_serial_data,M);
figure(17),
subplot(2,1,1), stem(data_source);
grid on;xlabel('Data Points');ylabel('Amplitude');
title('Original Data')
subplot (2,1,2),
stem(qam_demodulated_data,'bo');
grid on;xlabel('Data Points');ylabel('Amplitude');
title('Recieved Data')
Walter sir I somehow managed to write the code,Now my code has two problem,Channel should be optical fiber channel not wireless channel,at the last I am getting graph like
you can see in received signal and original data graph x axis is not giving same value,in original data x axis is 200,400..and received data x axis is 20,40..so what changes need to be done in the coding so that in both cases x axis should give me same value,please help.

Dipsikha Roy
Dipsikha Roy on 12 Feb 2021
Sir please help me how can I implement rayleigh fading channel here instead of AWGN channel.

Communities

More Answers in the  Power Electronics Control

Categories

Find more on Propagation and Channel Models in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!