0

I'm trying to plot the Gauss sums according to the equation shown in the image s(t), but I keep receiving errors. Can you please show me what am I doing wrong ?

enter image description here

enter image description here

%%
Fs = 1000;                    % Sampling frequency
T = 1/Fs;                     % Sampling period
L = 1024;                     % Length of signal
t = 2*(0:L-1)*T;               % Time vector
x = 0;
k = 0;
s = 0;
p = primes(L);
% s(t) = cumsum((k/p)(1:length(p)-1)).*exp(1i*k*t);
for k=1:p-1
    
s(t) = s(t) + (k/p).*exp(1i*k*t);
    
end
figure
subplot(2,2,1)
plot(t,s)
title('signal')
flawr
  • 10,814
  • 3
  • 41
  • 71

1 Answers1

0

You're treating the Legendre symbol as fraction - which it is not despite the deceivingly similar appearance.

Furthermore the index for your summation doesn't make a whole lot of sense, you probably just wan to use s as summing variable. So you just have to replace k/p in your summation expression with the Legendre symbol.

flawr
  • 10,814
  • 3
  • 41
  • 71
  • is there a function for the legendre symbol that I should use ? what do you mean by "the index for your summation doesn't make a whole lot of sense" ? – Mohamed El. Jan 24 '22 at 16:15
  • If `s` is an array you can't use non-integral indices `t`. You should just use `s` as a vector. I don't think there is a built in legendre symbol function, you're probably gonna have to write one yourself. – flawr Jan 24 '22 at 16:21
  • I edited the code a little bit and added the jacobiSymbol function, but I still keep getting errors – Mohamed El. Jan 24 '22 at 23:02
  • It seems now you have problems unrelated to your first question. Please ask a separate question and do not forget to include an [MCVE]. You shouldn't edit a post to ask a new question but creat a new post instead. – flawr Jan 25 '22 at 10:40