Clear CLC NC 200 T (-2:0.01:2) F Zeros (401,1) F (1:201) 0 F (202:401) 2 Plot (T, F,,, 3) Hold s1 Zeros (1,401) N 1:2:nc fc1 (4) / (N Pi) Sin (N (Pi/2) ) s1 s1+fc1 S 1+s1 Plot (T, S,)

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

3.

clear all;
clc;
nc=200
t=[-2:0.01:2];
f=zeros(401,1);
f(1:201)=0;
f(202:401)=2
figure
plot(t,f,'black','LineWidth',3);
hold on
s1=zeros(1,401);
for n=1:2:nc
fc1=(4)/(n*pi)*sin(n*(pi/2));
s1=s1+fc1;
end
s= 1+s1
plot(t,s,'b')

8.
clear all;
clc;
nc=200
x=[0:0.01:1];
x1=[1:0.01:2];
t=[0:0.01:2];
f=zeros(1,201);
f(1:101)=x;
f(101:201)=(1-x1);
figure
plot(t,f,'black','linewidth',2);
ylim([-3 3])
xlim([-0.5 2.5])
hold on
S1=zeros(1,201);
for n=1:2:nc
c=n*pi;
fc1=-4*(cos(c*t)/((c).^2))+2*(sin(c*t)/c)
S1=S1+fc1;
end
s=0+S1;
plot(t,s,'blue')

12.
clear all;clc
nc=100
x=[-1:0.01:1];
t=[-1:0.01:1];
f=zeros(1,201)
f(1:201)=(pi/2)*x.^3;
figure
plot(t,f,'black','linewidth',3);
ylim([-3 3]);
xlim([-1.5 1.5]);
hold on
S1=zeros(1,201);
S2=zeros(1,201);
for n=1:2:nc
v=n*pi;
fc1=(pi/v-6*pi/v.^3)*sin(v*t);
end
for n=2:2:nc
m=n*pi;
fc2=(-pi/m+6*pi/m.^3)*sin(m*t);
S2=S2+fc2;
end
s=0 +S1+S2
plot(t,s,'blue')

You might also like