I am trying to run the given code below
w = fft(y);
a1 = abs(w);
a2= a1(0:length(w)/2-1);
g = (0:(length(w)/2)-1)*fs/length(w);
figure;
subplot(2,1,1)
plot(g,a2);
title('FFT of X(k): Original signal');
xlabel('frequency(hz)');
ylabel('amplitude of frequency');
at the
a2 = a1(0:length(w)/2-1);
matlab shows an error
"Subscript indices must either be real positive integers or logicals."
I have no idea what's going wrong.