How can I lengthen a time-domain signal using IFFT reconstruction?

2 views (last 30 days)
The following script is intended to result in a signal identical to the input signal, only twice as long in the time-axis. Instead, it results in a signal that is twice as many data points, but half the frequency of the original signal when plotted with the same time scale. It appears I'm using IFFT incorrectly. Is there a way to do this?
function [ output_args ] = lvm_recon(filename)
%LVM_RECON Reconstruct time domain signal
% This function imports a time-domain current signal
% from an lvm file, then performs FFT and reconstructs
% the signal in order to make it periodic and
% lengthen its original duration.
lvmdata = lvm_import(filename,0);
%Create time axis
L = length(lvmdata.Current);
time_step = 1/lvmdata.Fs;
t_axis = (0:(L-1))*time_step;
%plot original time signal
figure(1);
plot(t_axis,lvmdata.Current);
ylabel('Amperes');
xlabel('Seconds');
title('Original Current Waveform');
%subtract mean from the data
m = mean(lvmdata.Current);
lvmdata.Current = lvmdata.Current - m;
%Perform FFT
NFFT = 2^nextpow2(L); % Next power of 2 from length of y
Y = fft(lvmdata.Current,NFFT)/L;
%Generate frequency axis with NFFR/2+1 points
%between the values of 0 and Fs/2
f = lvmdata.Fs/2*linspace(0,1,NFFT/2+1);
% Plot single-sided amplitude spectrum.
figure(2);
plot(f,2*abs(Y(1:NFFT/2+1)));
xlabel('Frequency (Hz)');
ylabel('Magnitude');
%reconstruct the signal adding back in the mean
Z = 2*L*ifft(Y,2*L)+m;
%plot new time signal
t_axis = (0:(2*L-1))*time_step;
figure(3);
plot(t_axis,Z);
ylabel('Amperes');
xlabel('Seconds');
title('New Current Waveform');
output_args = Z;
end

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!