# Waveform not staring at origin

15 views (last 30 days)
sudhanva agartha on 31 Jan 2021
Commented: David Goodmanson on 31 Jan 2021
Hello,
Trying to perfom re-constructed time-domain signal(trapezoidal) using fourier series, have got the waveform but the vertical axis is shifted below origin.
Want the output waveform at origin, Kindly HELP!!
clc;
clear all;
N=150; %number of harmonics
T=1; %period of signal, in s
TR=T/8; %rise time
TF=T/8; %fall time
L=T/2; %pulse width tau= T/2
f0=1/T; %frequency of signal
w0=2*pi*f0; %angular frequency
A=1; %amplitude
dt=1E-3;
t=0:dt:2*T; %time vector
%
%
% %Reconstruction of triangular wave
%
c0=0.375;
c=zeros(1,N);
x=ones(1,size(t,2))*c0;
for n=1:N
c(n)=A*(L/T)*(sin(0.5*n*w0*L)/(0.5*n*w0*L))*(sin(0.5*n*w0*TR)/(0.5*n*w0*TR))*exp(-j*n*w0*(TR+L/2));
x=x+2*abs(c(n))*cos(n*w0*t+angle(c(n)));
end
figure, plot(t,x);
title(['Trapezium wave reconstructed with ', num2str(N), ' harmonics']);
xlabel('t, s');
ylabel('x(t)');
clear y;
clear x;

David Goodmanson on 31 Jan 2021
Edited: David Goodmanson on 31 Jan 2021
Hi SA,
If you temporarily set c0 = 0 you obtain a nice trapezoidal wave of amplitude 1 that oscillates about y = 0 and has a mean of 0. The only purpose of c0 is to set the mean. By 'starting at the origin' I presume you mean that the constant part of the lower half of the waveform should be at y = 0. For reasons not clear to me you have set c0 = .375. Setting c0 = 1/2 results in a wave that oscillates between y = 0 and y = 1.

sudhanva agartha on 31 Jan 2021
C0 = 0.375 is the fourier expansion co-efficent and cannot be zero
David Goodmanson on 31 Jan 2021
Hi SA,