How to resolve"Unable to perform assignment because the left and right sides have a different number of elements."?
조회 수: 5 (최근 30일)
이전 댓글 표시
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
채택된 답변
Walter Roberson
2024년 2월 10일
이동: Walter Roberson
2024년 2월 10일
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.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Pulsed Waveforms에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!