%generamos una curva clear dt=0.5; t=0:dt:1e5; y=cos(2*pi*t*0.1)+0.01*cos(2*pi*t*0.025); figure(1),plot(t(1:500),y(1:500)); %% %obtenemos la FFT y normalizamos: fy=fft(y)*2/length(t); %obtenemos la potencia espectral (módulo cuadrado de la FFT) fyp=abs(fy).^2; %GENERAMOS EL VECTOR DE FRECUENCIAS!!! dw=1/max(1e5); wmax=1/dt; w=[0:length(t)-1]*dw; %wmax y el máximo de este vector deberían ser iguales figure(43),plot(w,fyp); %% %cortamos el vector para que quede más prolijo wp=floor(length(t)/2); w2=w(1:wp); figure(43),plot(w2,fyp(1:wp)); %% %mejoramos la figura figure(43),plot(w2,fyp(1:wp),'LineWidth',2),grid,axis([0 1 0 1.1]),box on %agregamos rotulos Y UNIDADES en los ejes xlabel('\nu [Hz]','fontsize',14),ylabel('potencia espectral [1/Hz]','fontsize',14) set(gca,'FontSize',13); drawnow; %% figure(43),semilogy(w2,fyp(1:wp),'LineWidth',2),grid,axis([0 1 1e-20 2]),box on xlabel('\nu [Hz]','fontsize',14),ylabel('potencia espectral [1/Hz]','fontsize',14) set(gca,'FontSize',12) set(gca,'XTick',[0.025 0.1 0.2 0.4 0.6 1]) set(gca,'XTickLabel',{'.025' ,'0.1','0.2','0.4','0.6','1.0'}) %% %agregar texto text(0.6,1e-5,'FFT','fontsize',18); text(0.3,1e-8,'$$X(k)=\sum_{j=1}^{N}x(j)e^{-\frac{2\pi i}{N}(j-1)(k-1)}$$',... 'Interpreter','latex','fontsize',16) ;