unable to perform assignment because left and right sides have a different number of elements
Show older comments
Hello there,
I have this problem when implementing my main and my function called "due".
MAIN
clc
clear
format long
set(groot,'DefaultAxesFontSize',14)
set(groot,'DefaultLineLineWidth',1.5)
load('Ex1T2_mistery_signal.mat');
sample = generateGoldCodeSampled(1,6.5e6,1.023e6,1);
corr = zeros(10,6500);
for i = 1:10
corr(i,:) = due(i, sample);
figure (i)
plot (0:6499, corr(1,(0:6499)+1))
grid on
end
FUNCTION DUE
function corr = due(PRN, signal_2)
pseudo_signal = generateCAcode(PRN);
signal_1 = zeros(1,6500);
signal_1(1:1023) = pseudo_signal(1:1023);
signal_1(1024:2047) = pseudo_signal(1:1023);
signal_1(2048:3071) = pseudo_signal(1:1023);
signal_1(3072:4095) = pseudo_signal(1:1023);
signal_1(4096:5119) = pseudo_signal(1:1023);
signal_1(5120:6143) = pseudo_signal(1:1023);
signal_1(6144:6500) = pseudo_signal(1:1023);
corr = zeros(1,6500);
for k = 1:6500
for j = 1:6500
if (j+k-1 <= 6500)
corr(1,k) = corr(1,k)+signal_1(j)*signal_2(j+k-1);
else
corr(1,k) = corr(1,k)+signal_1(j)*signal_2(j+k-6501);
end
end
end
end
In what way is the array assignment operation wrong?
Indeed, this is the error that I get!
Unable to perform assignment because the left and right sides have a different number of elements.
Error in due (line 7)
signal_1(1024:2047) = pseudo_signal(1:1023);
Error in maindue (line 13)
corr(i,:) = due(i, sample);
PS
pseudosignal is just a sequence of +1 and -1.
Thank you!
Accepted Answer
More Answers (0)
Categories
Find more on Subplots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!