where is the wrong this code!

2 views (last 30 days)
Akash Barua
Akash Barua on 30 Jan 2023
Answered: Cris LaPierre on 30 Jan 2023
where is the wrong in this code.i can't run this code
clear; clc;
% Modulation schemes to compare
modulations = {'BPSK', 'QPSK', '8-PSK', '16-QAM', '64-QAM'};
% Transmit power and data rate
P_t = 0.1; % W
R = 100e6; % bps
% Extinction coefficient
c = 0.15; % m^-1
% PIN PD parameters
eta = 0.82;
fc = 300e6; % Hz
% Rx parameters
d = 0.2; % m
f = 0.25; % m
fov = 0.69;
% BER calculation
for i = 1:length(modulations)
modulation = modulations{i};
% Assume ideal receiver for simplicity
[~, ber(i)] = berawgn(modulation, R, P_t);
end
Error using berawgn
EbNo must be a real vector.
% Plot BER results
semilogy(1:length(modulations), ber, '-o');
xlabel('Modulation');
ylabel('BER');
xticks(1:length(modulations));
xticklabels(modulations);
grid on;

Answers (1)

Cris LaPierre
Cris LaPierre on 30 Jan 2023
The first input to berawgn must be a scalar or vector. Your first input is a character vector that seems to what is expected as the second input (modtype).
The first input argument, EbNo, is the ratio of bit energy to noise power spectral density in dB (Eb/N0).
Consult the documentation to be sure you are supplying the inputs the function expects.

Community Treasure Hunt

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

Start Hunting!