anyone help please i only need to solve the domain problems from frequency to time. 10 points in time domain but 512 points in frequency domain
Matlab simulation problem about ifft
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
My problem is that i cannot reconstruct to the input signal (random binary signal) x(t) by using ifft from frequency domain to time domain.Even a square wave, i cannot reconstruct to x(t) after Y = fft(A,nfft).please someone help
clear;
%This is an input signal, x(t)
for i = 0:9
A(i*10+1:i*10+10) = (rand(1)>0.5);
end
X = (1:10*(9+1));
%Fourier transform of a square wave pulse with time interval 1 ns each by
%taking 512 point.
T = 1e-09;
Fs = 1/T;
nfft = 512;
Y = fft(A,nfft);
Y = Y(1:nfft/2);
mx = Y;
f = (0:nfft/2-1)*Fs/nfft;
%Plotting random binary signal,x(t)
figure(1);
subplot(2,1,1); stem(X/10,A);
xlim([0 15]); ylim([-1.5 1.5]);
title('Random binary Signal');
%Plotting fourier transform of random binary signal
subplot(2,1,2); plot(f,mx);
title('Fourier Transform of a random binary');
0 comentarios
Respuestas (5)
Rick Rosson
el 26 de Feb. de 2014
In your code, I see where you have defined A as a function of X, but I do not see where you have defined x as a function of t. In fact, there is no vector of time values at all. Furthermore, the code computes Y as the FT of A whereas the block diagram shows that Y is the output of a system with transfer function of H. Also, the code makes no use of the ifft function, which is the main focus of your question.
Please re-write your code so that it represents what the block diagram shows. You may want to start by defining x as a function of t where t is a vector of time values with increment of 1 ns.
HTH.
0 comentarios
Rick Rosson
el 26 de Feb. de 2014
Editada: Rick Rosson
el 26 de Feb. de 2014
Here is a start:
dt = 1e-9;
Fs = 1/dt;
N = 10;
t = dt*(0:N-1)';
x = (rand(10,1) > 0.5);
X = fft(x);
dF = Fs/N;
f = ...
H = ...
Y = H.*X;
y = ifft(Y);
...
...
HTH.
0 comentarios
Rick Rosson
el 27 de Feb. de 2014
Editada: Rick Rosson
el 27 de Feb. de 2014
Let me introduce some commonly used terminology that I think will help you out. Based on what you are saying, you want to have a binary signal x( t ), consisting of randomly-generated 0's and 1's. The symbol time of your signal will be 1 nanoseconds per symbol, corresponding to a symbol rate of 1 x 10^9 symbols per second. The signal will have an oversampling rate of 10 samples per symbol, so that the sampling rate will be 10 x 10^9 samples per second, corresponding to a sampling time of 0.1 nanoseconds per sample.
Does that make sense?
Here is some code that should help you get started:
% Oversampling rate (in samples per symbol):
oversamplingRate = 10;
% Symbol time (in seconds per symbol):
symbolTime = 1e-9;
% Number of symbols:
N = 200;
% Create binary signal:
b = double(rand(1,N) > 0.5);
x = repmat(b,oversamplingRate,1);
x = x(:);
% Simulation start and stop times (in seconds):
startTime = 0;
stopTime = startTime + N*symbolTime;
% Sampling time (in seconds per sample):
dt = symbolTime/oversamplingRate;
% Sampling rate (in samples per second):
Fs = 1/dt;
% Vector of time values (in seconds):
t = (startTime:dt:stopTime-dt)';
figure;
stem((0:N-1)',b);
ylim([-0.2 1.2]);
xlabel('Index number');
figure;
stem(t/1e-9,x);
ylim([-0.2 1.2]);
xlabel('Time (in nanoseconds)');
I hope that helps.
Rick
3 comentarios
Rick Rosson
el 27 de Feb. de 2014
Editada: Rick Rosson
el 27 de Feb. de 2014
- Please format your code so that it is more readable.
- I modified my code a little bit since you tried it, please check the new version and try it again. The modification is fairly superficial - it is mainly to make the code a bit more robust.
Rick Rosson
el 27 de Feb. de 2014
Editada: Rick Rosson
el 27 de Feb. de 2014
Remember, that Xw is complex-valued. When you call the plot function:
plot(f,Xw);
MATLAB will plot only the real-part of Xw while completely ignoring the imaginary-part. Please take a look at the MATLAB Command Window and you should see a Warning message to this effect.
What you should do instead is to plot the magnitude of Xw and/or the phase. Please try:
plot(f,abs(Xw)); % magnitude response
and/or
plot(f,angle(Xw); % phase response
I think that may resolve the issue.
Here are the two plots:
Ver también
Categorías
Más información sobre Spectral Measurements en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!