having trouble modulating signal
Afficher commentaires plus anciens
clear
close all
clc
%% defines the functions and their periods
syms t n t1 t2
One(t1,t2) = heaviside(t-t1) - heaviside(t-t2);
u(t) = heaviside(t);
r(t) = t*u(t);
A = 1;
t0 = 1;
m1 = A/(5-t0);
m2 = -A/t0;
m3 = -A/(5-t0);
m4 = A/t0;
y = m1*(r(t)-r(t-(5-t0)) ) + m2*(r(t-(5-t0))-r(t-5) ) + m3*(r(t-5)-r(t-(10-t0))) + m4*(r(t-(10-t0))-r(t-10));
T = 10;
I = [ 0 T ]; % Intervals per row
figure
fplot( t , y , [0 , T] )
title('Original Function')
xlabel('t')
ylabel('v(t)')
grid minor
%% Complex form
% Number of harmonics
N = 24;
for i = 1 : length(T)
% The symbolic Coefficients
Cn(i) = (1/T(i))*int(y(i)*exp(-1j*(2*pi*n*t/T(i))), t, I(i,1), I(i,2));
for j = 1 : 2*N+1
nj = -N+(j-1); % it goes from -N to N passing through 0
w0i = 2*pi/T(i);
% The numeric Coefficients
CnV(i,j) = eval(limit( Cn(i) , n , nj ));
if nj < 0
Exp(i,j) = 2*abs(CnV(i,j))*cos( -w0i*nj*t - angle(CnV(i,j)) );
end
end
% The fourier series is coseine expresion, [-N,-N+1,-N+2,...]
FS(i) = sum( Exp(i,:) ) + CnV(i,N+1);
end
%%
figure
subplot(2,2,[1,3])
fplot( t , FS(1) )
title('Fourier signal')
xlabel('time')
ylabel('Signal')
grid minor
subplot(2,2,2)
stem( -N:N , abs(CnV(1,:)) )
title('Magnitude')
xlabel('n')
ylabel('|C_n|')
grid minor
subplot(2,2,4)
stem( -N:N , angle(CnV(1,:)) )
title('Phase')
xlabel('n')
ylabel('\angle C_n')
grid minor
Réponses (0)
Catégories
En savoir plus sur Calculus dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!