フィルターのクリア

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

6 ビュー (過去 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

採用された回答

Walter Roberson
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.
  1 件のコメント
Basmah Ahmad
Basmah Ahmad 2024 年 2 月 10 日
移動済み: Walter Roberson 2024 年 2 月 10 日
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!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangePulsed Waveforms についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by