Borrar filtros
Borrar filtros

How to resolve"Unable to perform assignment because the left and right sides have a different number of elements."?

6 visualizaciones (últimos 30 días)
Why i am getting this error?
Unable to perform assignment because the left and right sides have a different number of elements.
Error in goldkasamiikron (line 29)
y(idx) = exp(1i * arg) .* newCode(1:length(idx));
function y = goldkasamiikron(fs, prf, pw, bw, fcent)
% Compute pulse repetition interval (PRI)
pri = 1 / prf;
% Create time vector for one PRI
t = 0:1/fs:pri;
code1 = comm.GoldSequence('FirstPolynomial','x^6+x^5+1', 'FirstInitialConditions',[ 0 0 0 0 0 1], 'SecondPolynomial','x^6+x^5+x^4+x+1', 'SecondInitialConditions',[0 0 0 0 0 1], 'Index',1, 'SamplesPerFrame',63);
gold_code = code1();
gold_code = 2.*gold_code - 1;
% Generate second kasami code
kasamiseq = comm.KasamiSequence('Polynomial',[6 5 4 1 0], ...
'InitialConditions',[ 0 0 0 0 0 1],'SamplesPerFrame', 63);
kasami_code = kasamiseq();
kasami_code = 2.*kasami_code - 1;
% Construct new code
newCode = kron(gold_code, kasami_code); % Construct new code using Kronecker product
% Frequency limits
fl = fcent - bw/2;
fh = fcent + bw/2;
% Create pulsed waveform
y = zeros(size(t));
idx = find(t <= pw);
arg = 2 * pi * fl * fh / bw * pw * log(1.0 - bw * t(idx) / fh / pw);
y(idx) = exp(1i * arg) .* newCode(1:length(idx));
end

Respuesta aceptada

Walter Roberson
Walter Roberson el 10 de Feb. de 2024
Movida: Walter Roberson el 10 de Feb. de 2024
My guess at the moment is that you are operating on a combination of row vector and column vector, which would give you a full 2D array as a result.
My guess is that newCode(1:length(idx)) comes out as a column vector.
  1 comentario
Basmah Ahmad
Basmah Ahmad el 10 de Feb. de 2024
Movida: Walter Roberson el 10 de Feb. de 2024
Yes, Mr Walter Roberson your guess was right. It was a column vector and when i changed it to row vector, i got my result. Thank you!

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by