Facebook
From Baby Lemur, 6 Years ago, written in Plain Text.
This paste is a reply to Untitled from Tacky Curlew - go back
Embed
Viewing differences between Untitled and Re: Untitled
clear all
close all

f0=250;
f1=500;
fs = 2000;
Nf = 50

M = Nf;
nx = 0:M-1; 
dt = 1/fs; 
t = dt*nx;

h = fir1(Nf, ((f0+f1)/2)  /  (2*fs));
x = cos(2*pi*f0*t) + cos(2*pi*f1*t);
tic;
y1 = conv(h, x);
toc;



tic;
xp = [x zeros(1, Nf-1)];
L=ceil(log2(length(xp)));
xp=[xp zeros(1, 2^L-length(xp))];

bp=[h zeros(1, M-1)];
bp=[bp zeros(1,2^L-length(bp))];

Xp=myFFT(xp');
Bp=myFFT(bp');
Y=Xp.*Bp;
y3=real(ifft(Y));
toc;
plot(1:500, y1(1:500), 1:1024, y3(1:1024));
title('Splot');
xlabel('Próbki');
ylabel('Wartość splotu');
legend('Splot z funkcji conv', 'Splot przy pomocy myFFT', 'Location', 'se');


figure(2)
plot(20*log10(abs(fft(y3))));
title('Widmo sygnału wyjściowego')
xlabel('Próbki')