I'm trying to write an if-else statement that sets a value of an array to 0.1 at n=0 because the equation that computes that array has undetermined value at that input. The equation is:
So at 0 the value is infinity.
This is the code I wrote but it doesn't seem to work:
n = -(N-1)/2:(N-1)/2;
hlp = (1./n*pi).*(sin(0.1*pi.*n));
if n == 0
hlp = 0.1;
else
hlp = (1./n*pi).*(sin(0.1*pi.*n));
end

nis nevern==0, asn = -(N-1)/2:(N-1)/2;. Your code would work with a couple of changes: make a for loopfor ii=n, and then access each variable per value (n(ii)andhlp(ii)). That is what is flawed in your logic. The one liner solution is better, but sometimes you can't avoid loops.