Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

How to convert frequency spectrum to time domain waveform

1 vue (au cours des 30 derniers jours)
amrinder
amrinder le 24 Avr 2013
Hello everybody, There is one problem here i am getting. I have taken some data in labview then converted into project6.mat file and then applied following commands to get timewaveform signal figure file and its FFT spectrum figure file.
Then i modified/clipped/removed some signals in FFT spectrum figure file which are not required. Now i want to obtain the Time waveform Figure file as well as the .mat file converting data from the FFT figure file i have changed.......
Th code giving Time domain and FFT spectrum is
load Project6
x1 = x1(:,2); % samplerate=25600;
fs=samplerate;
n = length(x1);
t0 = 0; % initial time
tf = 1.28;% final time
tspan = 1/n;
ntspan =(tf-t0)*tspan;
t = (t0:ntspan:tf);
figure(1)
plot (t(1:32768),x1,'r','linewidth',1)
grid on
xlabel('Time (sec)','Fontname','Times new roman','FontSize',35,'fontweight','b')
ylabel('Amplitude (Volts)','Fontname','Times new roman','FontSize',35,'fontweight','b')
set(gca, 'FontName','Times New Roman','FontSize',35,'fontweight','b')
% % -----------------------------FFT ----------------------------------
out1=fft(x1,n)/n;
figure(2)
plot(fs/2*linspace(0,1,(length(out1)/2)+1),abs(out1(1:(length(out1)/2)+1)),'b','linewidth',4),title('One sided Spectrum','Fontname','Times new roman','FontSize',35,'fontweight','b')
grid on
xlabel('Frequency (Hz)','Fontname','Times new roman','FontSize',35,'fontweight','b')
ylabel('Amplitude (Volts)','Fontname','Times new roman','FontSize',35,'fontweight','b')
set(gca, 'FontName','Times New Roman','FontSize',35,'fontweight','b')
Hope i made myself clear about the problem, and expecting the good easy answer soon from you guys...
Thanx.....

Réponses (2)

Wayne King
Wayne King le 24 Avr 2013
Modifié(e) : Wayne King le 24 Avr 2013
If by "Then i modified/clipped/removed some signals in FFT spectrum figure file which are not required.", you mean that you removed 1/2 the frequency content
abs(out1(1:(length(out1)/2)+1))
Then you will have to add it back in order to get back to the original time domain signal. If you have only the "positive" frequencies you can fill out the DFT in order to invert the signal if you can assume the signal is real-valued.
For example,
Fs = 1000;
t = (0:1/Fs:1-1/Fs)';
x = cos(2*pi*100*t)+randn(size(t));
xdft = fft(x);
% signal is even length
xdft = xdft(1:length(x)/2+1);
Now I only have 1/2 the DFT, but if I know that x is real-valued
xdft = [xdft; conj(flipud(xdft(2:end-1)))];
xrec = ifft(xdft,'symmetric');
max(abs(x-xrec))
  1 commentaire
amrinder
amrinder le 25 Avr 2013
Thanx.. for the attention.. The output as obtained in FFT which is removing 1/2 the frequency content is my requirement initially so i have applied the code.
abs(out1(1:(length(out1)/2)+1))
but by "modified/clipping/removing" i mean to say that i myself removed some signals from the generated FFT graph.
i have applied ur code and got some similar results but there are few problems which i m getting here, before that i tell u what i did before applying ur code; Firstly the FFT modified by me(by removing some signals that are not required) i took their data and copied it to excel format. then i conveterd that data to matlab creating a project1.mat file. then i load this project1 file and applied ur code there. The code executed very well but Now here is still the problem persists
1) I required a time domain "plot" between time (on x-axis) and amplitude(on y-axis) where samplerate is 25600, time window will be from 0 to 1.28. There is no code u provided about how to plot between time-amplitude axis from 0 to 1.28.
2) Does this time domain graph which we will be plotting will give the same output of modified FFT graph when i apply my previous code i.e..
out1=fft(x1,n)/n;
figure(2)
plot(fs/2*linspace(0,1,(length(out1)/2)+1),abs(out1(1:(length(out1)/2)+1)),'b','linewidth',4),title('One sided Spectrum','Fontname','Times new roman','FontSize',35,'fontweight','b')
Kindly provide me easy steps as i am not a professional of Matlab.

amrinder
amrinder le 27 Avr 2013
kindly provide me some help as i m in urgent need and my work is suffering a lot coz of this problem

Cette question est clôturée.

Community Treasure Hunt

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

Start Hunting!

Translated by