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!