how to make an array with the constellation point of qam
Show older comments
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
More Answers (6)
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
on 29 Nov 2020
Edited: Dipsikha Roy
on 29 Nov 2020
Walter Roberson
on 29 Nov 2020
Sorry, I am not accepting any additional private contracts at the moment. I am dealing with a significant hardware problem, and I am having a lot of trouble keeping up with my existing obligations.
Dipsikha Roy
on 29 Nov 2020
Walter Roberson
on 29 Nov 2020
X = qammod(x, 8);
X(5:9) = -X(1:4);
Dipsikha Roy
on 29 Nov 2020
Dipsikha Roy
on 1 Dec 2020
Walter Roberson
on 1 Dec 2020
To remove that error, take the source code for the open source software Octave and modify the way that array indexing works for it, so that you can have a matlab-like language that permits a subscript of 0. But MATLAB itself is not going to gain the ability to index double array with 0 any time in the next few years.
Dipsikha Roy
on 1 Dec 2020
Walter Roberson
on 1 Dec 2020
qam_modulated_data(1:4)=-qam_modulated_data(5:8)
Dipsikha Roy
on 1 Dec 2020
Dipsikha Roy
on 1 Dec 2020
Edited: Dipsikha Roy
on 1 Dec 2020
Walter Roberson
on 1 Dec 2020
Edited: Walter Roberson
on 1 Dec 2020
X(1:4)=-x(5:8)
means
temporary = x;
X(1) = temporary(5);
X(2) = temporary(6);
X(3) = temporary(7);
X(4) = temporary(8);
The way this differs from
X(1) = x(5);
X(2) = x(6);
X(3) = x(7);
X(4) = x(8);
is that in the syntax
A(indices) = B(other_indices)
includes the possibility that A and B name the same variable and that there is overlap between indices and other_indices. For example,
X(2:5) = X(1:4)
if written out step by step the way you did, might give you the impression that the generated code would be
X(2) = X(1);
X(3) = X(2);
X(4) = X(3);
X(5) = X(4);
but if you look at those steps at code, notice that whatever was originally in X(1) gets copied to X(2), and then what is now in X(2) gets copied to X(3)... so what was originally in X(1) would get copied to X(3) then X(4) then X(5). But that is not what happens: the data source effectively gets copied to a temporary variable, and it the temporary variable that is copied out of, so you are always copying out the old contents, never the content that you just wrote into.
Also I recommend that you use names that are more different than x compared to X, as it is easy to get confused over what is being asked for. Are you wanting to copy from the original data x, or are you wanting to copy from the qammod output ?
Dipsikha Roy
on 1 Dec 2020
Edited: Walter Roberson
on 14 Dec 2020
Dipsikha Roy
on 1 Dec 2020
Edited: Dipsikha Roy
on 1 Dec 2020
Dipsikha Roy
on 5 Dec 2020
3 Comments
Walter Roberson
on 5 Dec 2020
You do not use hold on and you do not use subplot and you do not use figure and you do not use tiled layout. So when you stem(), that is going to automatically erase existing graphics.
Dipsikha Roy
on 5 Dec 2020
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.
Dipsikha Roy
on 14 Dec 2020
0 votes
18 Comments
Walter Roberson
on 15 Dec 2020
stem() can take two parameters. Pass the frequency in megahertz as the first parameter. See the first example in the fft() documentation for information on how to calculate the frequency.
Dipsikha Roy
on 15 Dec 2020
Dipsikha Roy
on 15 Dec 2020
Walter Roberson
on 15 Dec 2020
annotation('arrow') possibly? There are File Exchange contributions that make it easier to build the correct coordinates
I have no idea what you intend the arrows to represent.
Dipsikha Roy
on 22 Dec 2020
Edited: Walter Roberson
on 22 Dec 2020
Walter Roberson
on 22 Dec 2020
qam modulated data is complex valued. It contains components with positive and negative real parts, and components with positive and negative imaginary parts. You should not be using stem() on qam modulated data: stem() is only for real-valued data.
Dipsikha Roy
on 22 Dec 2020
Dipsikha Roy
on 1 Jan 2021
Edited: Walter Roberson
on 31 Jan 2021
Dipsikha Roy
on 25 Jan 2021
Dipsikha Roy
on 25 Jan 2021
Walter Roberson
on 26 Jan 2021
You did not post your code, so it is difficult to say. I suspect, though, that what you call qam_modulated_data is now not your qam_modulated_data and is instead your data with cyclic prefix, that is no longer the same size as before, and in particular is no longer no_of_data_bits in length.
Dipsikha Roy
on 26 Jan 2021
M =8; %here we initialize the number of constellation point of qam
no_of_data_bits=512;
Fm=10^6;%Max freq
block_size = 16; %Size of each OFDM block to add cyclic prefix
cp_len = floor(0.3 * 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);
udata1 = udata;
H = floor(length(udata)/2);
udata1(end-H+1:end) = conj(-udata(1:H)); % in my udata1 array last four point is Hermitian of first four point %CHANGED
figure(5);
x=1:nudata;
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:nudata;
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:nudata;
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=8;
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)),8);% 8 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(5), subplot(4,1,1),plot(real(A1),'r'),title('Cyclic prefix added to all the sub-carriers')
subplot(4,1,2),plot(real(A2),'c')
subplot(4,1,3),plot(real(A3),'b')
subplot(4,1,4),plot(real(A4),'g')
subplot(4,1,5),plot(real(A1),'r')
subplot(4,1,6),plot(real(A2),'c')
subplot(4,1,7),plot(real(A3),'b')
subplot(4,1,8),plot(real(A4),'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 stream for transmission,plot((real(A3)),'b'),hold on,
[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(6),plot(real(ofdm_signal)); xlabel('Time'); ylabel('Amplitude');
title('OFDM Signal');grid on;
%...............................................................
Passing time domain data through channel and AWGN
%.............................................................
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
figure(7),plot(real(recvd_signal)),xlabel('Time'); ylabel('Amplitude');
title('OFDM Signal after passing through channel');grid on;
%...........................................................
Walter Roberson
on 26 Jan 2021
You need to go back through and rework what you are doing. At any one point you need to decide whether you are working with:
- the signal to be transmitted
- the qam modulated version of the signal to be transmitted
- one copy of all M possible unique inputs, for the purpose of plotting showing all of the possible constellation points
- one copy of all the unique used qam modulated data, for the purpose of plotting showing all of the possible used constellation points
- an array for calculating sub-band information
- an OFDM block
What is the relationship (if any) between the number of subcarriers and M ? You set both of them to 8, but if they are certain to be equal then set the number of sub-carriers to M.
What is the relationship between the OFDM block size and anything else? Where are you stuffing data into an OFDM block in order to be able to extract it to build the cyclic prefix? Should you be doing the reshape() with respect to the OFDM block size instead of with respect to M ? If so what happens if the signal length is not a multiple of the OFDM block size?
Dipsikha Roy
on 26 Jan 2021
Edited: Dipsikha Roy
on 26 Jan 2021
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.
Dipsikha Roy
on 31 Jan 2021
0 votes
4 Comments
Walter Roberson
on 31 Jan 2021
You need to go back through and rework what you are doing. At any one point you need to decide whether you are working with:
- the signal to be transmitted
- the qam modulated version of the signal to be transmitted
- one copy of all M possible unique inputs, for the purpose of plotting showing all of the possible constellation points
- one copy of all the unique used qam modulated data, for the purpose of plotting showing all of the possible used constellation points
- an array for calculating sub-band information
- an OFDM block
What is the relationship (if any) between the number of subcarriers and M ? You set both of them to 8, but if they are certain to be equal then set the number of sub-carriers to M.
What is the relationship between the OFDM block size and anything else? Where are you stuffing data into an OFDM block in order to be able to extract it to build the cyclic prefix? Should you be doing the reshape() with respect to the OFDM block size instead of with respect to M ? If so what happens if the signal length is not a multiple of the OFDM block size?
Dipsikha Roy
on 31 Jan 2021
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
on 31 Jan 2021
Edited: Dipsikha Roy
on 31 Jan 2021
Dipsikha Roy
on 9 Feb 2021
Edited: Dipsikha Roy
on 9 Feb 2021
Dipsikha Roy
on 12 Feb 2021
0 votes
Communities
More Answers in the Power Electronics Control
Categories
Find more on Modulation 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!










