Вы находитесь на странице: 1из 2

Compact trigonometric fourier series of square wave:

clc
clear all
close all
t = linspace(-0.001,0.001,100000); % time
x=0;
for k=1:2:30;

x=x+((4*(sin(2*pi*k*t*1000)))/(pi*k)); % computes nd add the k-th terms of the


series
plot(t,x,'black');
grid on;
hold on

end
xlabel('time');
ylabel ('magnitude');
title('Square wave');

RECT:
t1=0:1:5;
t2=-5:1:0;
y1=ones(size(t1));
y2=zeros(size(t2));
t=[t2 t1];
y=[y2 y1];
plot(t,y)
hold on
plot(-t+5,y)
ylim([-5 5])

Вам также может понравиться