필터 지우기
필터 지우기

can you help me to fix this error in code?

조회 수: 2 (최근 30일)
Batuhan Samet Demirci
Batuhan Samet Demirci 2022년 12월 15일
댓글: Walter Roberson 2022년 12월 16일
% Set the parameters of the simulation
N = 10000; % number of symbols to simulate
snr_range = 5:30; % range of SNR values in dB
% Generate a QPSK symbol constellation
constellation = qammod(0:3, 4);
% Create a vector of complex Gaussian noise samples with zero mean and unit variance
noise = randn(1, N) + 1i * randn(1, N);
% Loop over the SNR values
for snr_db = snr_range
% Calculate the SNR in linear scale
snr = 10^(snr_db/10);
% Initialize the error counter
errors = 0;
% Loop over the symbols to be transmitted
for i = 1:N
% Select two random QPSK symbols
s1 = constellation(randi(4));
s2 = constellation(randi(4));
% Generate the Alamouti coded symbol
s = sqrt(1/2) * [s1 -s2*conj(s1); s2 conj(s1)];
% Generate two independent Rayleigh fading coefficients
h1 = sqrt(1/2) * (randn(1) + 1i * randn(1));
h2 = sqrt(1/2) * (randn(1) + 1i * randn(1));
% Calculate the received signal
r = h1 * s(1,:) + h2 * s(2,:) + noise / sqrt(snr);
% Decode the received signal using the Alamouti scheme
s_hat = sqrt(1/2) * [r(1) conj(r(2)); r(2) r(1)];
% Calculate the symbol error rate (SER) for this SNR value
errors= errors + sum(s1
= s_hat(1,1)) + sum(s2
=s
h
at(1,1))+sum(s2
= s_hat(1,2));
end
% Calculate the symbol error probability (SEP) for this SNR value
sep(snr_db - min(snr_range) + 1) = errors / (N * 2);
end
% Plot the symbol error probability curve
semilogy(snr_range, sep);
xlabel('SNR (dB)');
ylabel('SEP');
title('Alamouti Scheme in Rayleigh Fading MISO Channel with QPSK');

답변 (2개)

KSSV
KSSV 2022년 12월 15일
Replace
errors= errors + sum(s1
= s_hat(1,1)) + sum(s2
=s
h
at(1,1))+sum(s2
= s_hat(1,2));
with
errors= errors + sum(s1) + s_hat(1,1) + sum(s2=shat(1,1))+sum(s2=s_hat(1,2));
  댓글 수: 2
Batuhan Samet Demirci
Batuhan Samet Demirci 2022년 12월 15일
편집: Batuhan Samet Demirci 2022년 12월 15일
after replacing it i got this error;
Arrays have incompatible sizes for this operation.
what should we do now sir?
the question was;
Write a MATLAB program that calculates the symbol error probability of the Alamouti scheme via numerical simulation using the QPSK symbol constellation in a Rayleigh fading MISO channel with two transmit and one receive antenna for the SNR range of 5 to 30 dB.
Walter Roberson
Walter Roberson 2022년 12월 16일
sum(s2=shat(1,1))
Provided that you have not replaced sum with a variable, that sub-expression is equivalent to
sum('s2', shat(1,1))
Are you sure you want to do that, pass in an option named s2 to sum() ? Wouldn't you prefer a comparison == instead?

댓글을 달려면 로그인하십시오.


Image Analyst
Image Analyst 2022년 12월 15일
Read the FAQ starting from here:
There are lots of related error messages there and explains what causes them and how to avoid the problem.
  댓글 수: 1
Batuhan Samet Demirci
Batuhan Samet Demirci 2022년 12월 15일
thanks but i coudnt still make this code work. Anyone else can help me?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Modulation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by