How to resolve"Unable to perform assignment because the left and right sides have a different number of elements."?
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Basmah Ahmad
am 10 Feb. 2024
Verschoben: Walter Roberson
am 10 Feb. 2024
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
1 Kommentar
Akzeptierte Antwort
Walter Roberson
am 10 Feb. 2024
Verschoben: Walter Roberson
am 10 Feb. 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 Kommentar
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Pulsed Waveforms finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!