How to plot Gauss sums?

79 Views Asked by At

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')
1

There are 1 best solutions below

4
flawr On

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.