help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: using fft to resample data


From: Maynard Wright
Subject: Re: using fft to resample data
Date: Tue, 11 Oct 2016 08:48:17 -0700
User-agent: KMail/4.13.3 (Linux/3.16.0-30-generic; KDE/4.13.3; i686; ; )

On Friday, October 07, 2016 04:48:26 AM mat wrote:
> Hi,
> 
> I've got some frequency domain data which I want to process in the time
> domain then return to the freq domain for plotting. I want to upsample the
> input (sig) data to N_FFT length, and plot it against a new frequency vector
> as in 'y' below. The fft function seems to pad the data with zeros rather
> than upscale it (like Matlab does?). I'm doing some convolution in the time
> domain so fft'ing by the original length(sig) as in 'x', feels like it
> would lose data.
> 
> Sorry my maths isn't great....I may have just confused myself here.
> 
> 
> Example code:
> 
> N_FFT = 16384;
> 
> sig = rand(1,100);
> freq = (1:1:100);
> 
> 
> xt = ifft(sig,length(sig));
> 
> x = fft(xt,length(sig));
> 
> yt = ifft(sig,N_FFT);
> 
> y = fft (yt,N_FFT);
> 
> freq1 = (1:(max(freq)-1)/N_FFT:max(freq)-((max(freq)-1)/N_FFT));
> 
> figure;
> semilogx(abs(xt),'r');
> hold on;
> semilogx(abs(yt),'b');
> 
> figure;
> plot(freq,real(x),'y');
> hold on
> plot(freq,sig,'b');
> plot(freq,real(y(1:100)),'r');
> %plot(freq1,real(y),'r');
> 
> Best regards,
> 
> Mat.
> 
> 

A 2012 question on the Matlab Newsgroup discusses zero padding.  When I 
execute the example from the Newsgroup using Octave (admittedly an older 
version here, 3.8.1) I get the same results: a real time domain series, 
transformed and then zero padded, when transformed back to the time domain 
yields the same complex values as does the example.

Regards,

Maynard Wright




reply via email to

[Prev in Thread] Current Thread [Next in Thread]