Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function[f]=InterTryg(Y)
- n=length(Y)-1;
- for i = 0 : n
- X(i+1)=(2*i*pi)/(n+1);
- end
- if(mod(n,2)==0)
- d = 0;
- p = 0.5*n;
- else
- d = 1;
- p = 0.5*(n-1);
- end
- A=zeros(1,p+1);
- B=zeros(1,p+1);
- for i = 1 : p+1
- for j = 1: n+1
- A(i)=A(i)+Y(j)*cos((i-1)*X(j));
- B(i)=B(i)+Y(j)*sin((i-1)*X(j));
- end
- A(i) = A(i)*(2/(n+1));
- B(i) = B(i)*(2/(n+1));
- end
- syms x
- f = 0.5*A(1);
- for i = 1:p
- f = f +((A(i+1)*cos(i*x) + B(i+1)*sin(i*x)));
- end
- f = f + 0.5*d*cos(p+1)*x;
- f = simplify(f);
- ezplot(f)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement