I have data in frequency domain that looks like this:
This means I have a vector Y that contains the amplitude for the frequency points in the vector x. For example
f = [0 1 2 3 4 5 6 7 8 9 10]
Y = [0 0 0 0 0 1 0 0 0 0 0]
Performing an inverse fourier transform should give a sine wave with the frequency 5Hz.
The MATLAB function ifft can transform Y and f to time domain. Lets call the vectors in time domain y and t. I'm looking for a way how to get time domain data with a specified samplig frequency and a specified signal length. For example, I want time domain data with a signal length of 1 second and a sampling frequency of 1000Hz.
The output of MATLABs ifft function has always the same length as the input, so I'm not sure what to give as input to get the required sampling frequency and signal length.
To sum it up, I'm trying to write a MATLAB function
[t,y] = custom_ifft(f,Y,sampling_frequency,signal_length)
that converts the frequency domain data (f,Y) to time domain data (t,y), where the length of the time vector t can be specified in signal length (for example 1 second) and the sampling frequency ( length(y)/signal_length ) can be specified with sampling_frequency
EDIT: Please include in your answer the MATLAB code how to implement your idea. I already have the concept of how to do it, but I can't get the actual implementation to work. I'm specifically asking what to give as input argument to the ifft function:
y = ifft(input_arg);
I'm looking for MATLAB code how to create input_arg when (f,Y,sampling_frequency,signal_length) are known.
Here is my implementation that does not work as expected:
Y = [0 zeros(1,100) 1 0 0 zeros(1,500) 0 0 1 zeros(1,100)];
Y_interp = interp1(Y,linspace(1,length(Y),2*length(Y)));
y = ifft(Y) ;
y_interp = ifft(Y_interp);
figure;
plot(y);
figure;
plot(real(y_interp));
figure;
plot(abs(y_interp));