Last active
December 15, 2015 00:09
-
-
Save alastair/5171074 to your computer and use it in GitHub Desktop.
Matlab , upsampling sin waves
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%-- 03/15/2013 04:50:02 PM --% | |
fs = 11025; | |
r = 1/fs; | |
x = [0:r:1]; | |
y = sin(2 * pi * 400 * x); | |
NFFT = 2^nextpow2(11025); | |
Y = fft(y,NFFT)/11025; | |
f = fs/2*linspace(0,1,NFFT/2+1); | |
plot(f,2*abs(Y(1:NFFT/2+1))) | |
u2 = upsample(y, 2); | |
U2 = fft(u2,NFFT)/11025; | |
plot(f,2*abs(U2(1:NFFT/2+1))) | |
u4 = upsample(y, 4); | |
U4 = fft(u4,NFFT)/11025; | |
plot(f,2*abs(U4(1:NFFT/2+1))) | |
u8 = upsample(y, 8); | |
U8 = fft(u8,NFFT)/11025; | |
plot(f,2*abs(U8(1:NFFT/2+1))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment