- Communications Toolbox: https://in.mathworks.com/help/comm/index.html
- pskmod: https://in.mathworks.com/help/comm/ref/pskmod.html
- RaisedCosineTransmitFilter: https://in.mathworks.com/help/comm/ref/raisedcosinetransmitfilter.html
How to plot eye diagram of a given signal
51 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Mrinmoyee Mukherjee
el 26 de Mayo de 2022
Comentada: Mrinmoyee Mukherjee
el 24 de Sept. de 2023
Hello,
I have a square signal with the following signal parameters
- No of bits (N) =100
- Bit duration= Tb=1/N=0.01
- Sampling rate=5 *N=500
- Sampling time= (1/sampling rate)=0.002
I used the following steps to generate generate the square signal
- Generated random 100 bits using n=randi([0 1],1,N).
- Plotted it to check the correctness
- Scaled it to 0-5
I have written the following code
N=100; %Normalised bit rate-This is the frequency of signal, 10 bits/sec
Tb=1/N; % bit duration,%bit duration of each bit=0.1sec
%Total time scale=10*0.1=1sec
srate=5*N;%sampling rate >=2*signal frequency
tsamp=1/srate;%Sampling time
n=randi([0 1],1,N); %Generate random bits=N
i=1;
t=0:tsamp:length(n); %Generating the time scale to plot the random bits
for j=1:length(t)
if t(j)<=i
mod1(j)=n(i);
else
i=i+1;
end
end
for m=1:length(t)
if mod1(m)==0
nn(m)=0; %If zero no power is transmitted
else
nn(m)=5; %If one some power is transmitted in mW
end
end
figure (1)
subplot(2,1,1);
plot(t,mod1,'linewidth',2);
title('Random Generated Bits');
xlabel('No. of Bits');
ylabel('Amplitude');
axis([0 N -2 2]);
grid on;
subplot(2,1,2);
plot(t,nn,'linewidth',2);
title('Intensity Modulated Signal');
xlabel('No.of Bits');
ylabel('Power in mWatts');
axis([0 N 0 6]);
grid on;
nn1=nn';
eyediagram(nn1,500); %500 are the number of samples in each bit
I wanted to ask
- If this is the right approach to plot the eye diagram
- Is there any way to limit the y-axis of eyediagram
Thank you
0 comentarios
Respuesta aceptada
Moksh
el 22 de Sept. de 2023
Hi Mrinmoyee,
I understand that you have generated a random square signal and scaled it from the range [0, 1] to [0, 5]. I assume that you have performed this scaling to visualize the modulated version of the signal.
You can try using the modulation and transition functions in the “Communications Toolbox” in MATLAB for better results and then try using the “eyediagram” function.
Here is an example code using the Communications Toolbox:
% Generating random data and modulating it using QPSK modulation
data = randi([0 3],1000,1);
modSig = pskmod(data,4,pi/4);
% Transmitting the modulated signal using a raised cosine filter
sps=4; % Number of output samples per symbol parameter
txfilter = comm.RaisedCosineTransmitFilter('OutputSamplesPerSymbol',sps);
txSig = txfilter(modSig);
% Plotting the eyediagram for the transmitted signal
h = eyediagram(txSig,2*sps);
% Use the appropriate realtionship within h and it's children plots to
% modify the y limits of required plot
h.Children(4).YLim = [-0.5 0.5]; % Default ylims = [-1 1]
For changing the limits of the eye diagram, you can store the plot’s handle and use the appropriate parent-child relationship to edit the required limits. Edited limits for the first plot are demonstrated in the code above.
For more information about the toolbox and the above used functions, please refer to the following documentation:
Hope this information helps!
Best Regards,
Moksh Aggarwal
Más respuestas (0)
Ver también
Categorías
Más información sobre Test and Measurement en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!