%% prog002 ejemplo de amplitud serie fourier compleja clearvars; close all; clc; %% inicio %claculamos los coeficientes de Cn que van desde -N hasta N NCn = 101; for n1 = 1:NCn n(n1) = n1 - round(NCn/2) ; C(n1) = (1/2)*sin(n(n1)*pi/2)/(n(n1)*pi/2); end; %usamos limite notable C(51) = 1/2; figure(1) subplot(2,1,1) stem(n,abs(C)); title('modulo coeficientes de serie de fourier compleja'); xlabel('n'); ylabel('|C(n)|'); grid on; box on; subplot(2,1,2) stem(n,angle(C)); title('fase coeficientes de serie de fourier compleja'); xlabel('n'); ylabel('angle(C(n))'); grid on; box on; figure(2) subplot(2,1,1) stem(n,real(C)); title('parte real coeficientes de serie de fourier compleja'); xlabel('n'); ylabel('real(C(n))'); grid on; box on; subplot(2,1,2) stem(n,imag(C)); title('parte imaginaria coeficientes de serie de fourier compleja'); xlabel('n'); ylabel('imag(C(n))'); grid on; box on; %intervalo de analisis Tini = -5*pi; Tfin = 5*pi; dt = pi/100; FTini = -0.5*pi; FTfin = 1.5*pi; %tiempo t = Tini:dt:Tfin; %tiempo (arreglo 1D) Nt = length(t); %longitud del arreglo tiempo p = 1/2; %semiperiodo ft(1:Nt) = 0; %inicializamos la funcion con ceros for n1 = 1:NCn %trabajaremos usando el concepto de variable acumulativa ft = ft + C(n1)*exp(j*n(n1)*pi*t/p); %figura de como se van agregando los terminos cn figure(3) plot(t,ft) title('mi primera serie de fourier compleja Cn'); xlabel('tiempo t(s)'); ylabel('presion sonora p(Pa)'); legend(['f_n(t) n = ' int2str(n(n1))]); axis([Tini Tfin -0.5 1.5]); grid on; box on; %pausa cada 0.5 segundo pause(0.5) end; %% graficos finales figure(4) subplot(2,1,1) plot(t,real(ft)); title('parte real de la funcion serie de fourier compleja'); xlabel('n'); ylabel('real(f(t))'); legend('real(f(t))'); axis([Tini Tfin -0.5 1.5]); grid on; box on; subplot(2,1,2) plot(t,imag(ft)); title('parte imaginaria de la funcion serie de fourier compleja'); xlabel('n'); ylabel('imag(ft))'); legend('imag(f(t))'); axis([Tini Tfin -0.5 1.5]); grid on; box on; figure(5) subplot(2,1,1) plot(t,real(ft)); title('parte real de la funcion serie de fourier compleja'); xlabel('n'); ylabel('real(f(t))'); legend('real(f(t))'); axis([Tini Tfin -0.5 1.5]); grid on; box on; subplot(2,1,2) plot(t,imag(ft)); title('parte imaginaria de la funcion serie de fourier compleja'); xlabel('n'); ylabel('imag(ft))'); legend('imag(f(t))'); axis([Tini Tfin 1.1*min(imag(ft)) 1.1*max(imag(ft))]); grid on; box on;