Waveform not staring at origin

2 vues (au cours des 30 derniers jours)
sudhanva agartha
sudhanva agartha le 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;

Réponses (2)

David Goodmanson
David Goodmanson le 31 Jan 2021
Modifié(e) : David Goodmanson le 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
sudhanva agartha le 31 Jan 2021
C0 = 0.375 is the fourier expansion co-efficent and cannot be zero
  1 commentaire
David Goodmanson
David Goodmanson le 31 Jan 2021
Hi SA,
It's best to post a comment such as the one you made above a as comment rather than an answer.
By 'temporarily set' I meant that c0 = 0 was merely a temporary example. c0 can be set to any value you want. I would be interested to hear the reason for the value c0 = .375, since it conflicts with what I think the goal is, to have the bottom of the waveform at y = 0.

Connectez-vous pour commenter.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by