clc; close all; clear d=0.5; N=10; for n=1:N/2 sum=0; fderiv = @(f,x) (f(x+eps)-f(x))/eps; % Derivative of a function xderiv = @(x) ((x+eps)-x)/eps; % Derivative of an expression for k = 1:(N/2) x(k)=sin(2*(k+n-1)*pi/N)/(k+n-1) + sin(2*(k-n)*pi/N)/(k-n); if isnan( x(k) ) % Test for ‘NaN’ x(k) = fderiv(@sin, 2*(k-n)*pi/N)/(xderiv(k-n)); % L'Hospital's Rule end end sum=sum+x; an = (2/(N*pi))*(pi-sum); end display(an);% this is not giving the correct values????? an_manually=[-0.5736 -0.4197 -0.1352 0.2383 0.6486] % these are correct values
MATLAB: How to get correct values of a(n) from this equation. Attached is the code but it gives wrong values. where n=1…5,
for looploops
Best Answer