Incorrect dimensions for matrix multiplication.
Mostrar comentarios más antiguos
Could anyone help, please with explanation?
V=1+((exp(-0.5*t))*((-0.9)*(cos(1.323*t))-(0.34)*(sin(1.323*t))));
Error using *
Incorrect dimensions for matrix multiplication. Check that the number
of columns in the first matrix matches the number of rows in the
second matrix. To perform elementwise multiplication, use '.*'.
Thank you in advance.
Respuesta aceptada
Más respuestas (1)
% Parameters
M = 50; % Number of antennas
K = 3; % Number of terminals
L_prime = 9; % Number of paths
SNR_dB = 20; % SNR in dB
numSymbols = 1000; % Number of QPSK symbols to transmit
% Convert SNR from dB to linear scale
SNR_linear = 10^(SNR_dB / 10);
% Generate random QPSK symbols for each terminal
data = randi([0 3], K, numSymbols); % QPSK symbols
qpskMod = exp(1j * pi/4 * (2*data + 1)); % QPSK modulation
% Channel matrix
H = (1/sqrt(2*L_prime)) * (randn(M, K, L_prime) + 1j*randn(M, K, L_prime));
% Transmit the symbols through the channel with L' paths
rxSignal = zeros(M, numSymbols);
for l = 1:L_prime
rxSignal = rxSignal + sqrt(1/L_prime) * H(:,:,l) * qpskMod;
end
% Add noise
noise = (1/sqrt(2*SNR_linear)) * (randn(M, numSymbols) + 1j*randn(M, numSymbols));
rxSignalNoisy = rxSignal + noise;
% MRC Receiver
H_combined = sum(H, 3); % Sum the channel gains over the L' paths
mrcWeights = H_combined';
size(mrcWeights)
size(rxSignalNoisy)
mrcSignal = mrcWeights .* rxSignalNoisy; % Elementwise multiplication
% ZF Receiver
zfWeights = pinv(H_combined);
zfSignal = zfWeights * rxSignalNoisy;
% Constellation diagrams
figure;
subplot(1, 2, 1);
plot(real(mrcSignal(:)), imag(mrcSignal(:)), 'o');
title('Constellation Diagram (MRC)');
xlabel('In-Phase');
ylabel('Quadrature');
grid on;
axis([-2 2 -2 2]);
subplot(1, 2, 2);
plot(real(zfSignal(:)), imag(zfSignal(:)), 'o');
title('Constellation Diagram (ZF)');
xlabel('In-Phase');
ylabel('Quadrature');
grid on;
axis([-2 2 -2 2]);
sgtitle('Constellation of Estimated Symbols for K=3, M=50, L''=9, \rho=20 dB');
2 comentarios
PROSPER
el 9 de Jul. de 2024
check these codes and correct them for me
Torsten
el 9 de Jul. de 2024
To use elementwise multiplication, both arrays have to be of the same size. This is not the case here (see above). Maybe you mean matrix multiplication:
mrcSignal = mrcWeights * rxSignalNoisy; % Matrix multiplication
This would work.
Categorías
Más información sobre QPSK en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!