Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Frequency domain representation of time domain signal(Matlab

Status
Not open for further replies.

moonnightingale

Full Member level 6
Joined
Sep 17, 2009
Messages
362
Helped
5
Reputation
10
Reaction score
5
Trophy points
1,298
Activity points
3,832
I want to have frequency domain representation which is fourier transform of a signal. For example I am having function Cos(t). If i reprsent in frequency domian i will have two pulses one at (f - fo) and other at (f+fo). How can i see this in Matlab.plz help
 

Welcome to Matlab! You will find that it is extremely useful for this type of analysis. It has many built-in capabilities for transforming between frequency and time domain.

The thing to remember is that Matlab does everything numerically, not symbolically. As a result, you usually end up operating with series of data stored in vectors.

Here is an example I put together for you. We define a cosine wave with a frequency of 10 Hz. We then perform a fourier tranfsorm and view its frequency content. As expected, we see two peaks, one at -10 Hz, and the other at +10 Hz. You can copy and paste everything below directly into the command line, or it would be better to paste it into and m file.



%Define number of samples to take
number_of_samples = 2^10;
cosineFreq = 10; %Hz

%Define signal
t = linspace(0, 10, number_of_samples);
signal = cos(2*pi*cosineFreq*t);

%Plot to illustrate that it is a sine wave
plot(t, signal);
title('Time-Domain signal');

%Take fourier transform
fftSignal = fft(signal);

%apply fftshift to put it in the form we are used to (see documentation)
fftSignal = fftshift(fftSignal)

%Next, calculate the frequency axis, which is defined by the sampling rate
T = t(2)-t(1);
fs = 1/T;
f = fs/2*linspace(-1,1,number_of_samples);

%Since the signal is complex, we need to plot the magnitude to get it to
%look right, so we use abs (absolute value)
figure
plot(f, abs(fftSignal));
title('magnitude FFT of cosine');
xlabel('Frequency (Hz)');
ylabel('magnitude');
 

Re: Frequency domain representation of time domain signal(Ma

Thanks a lot for ur detailed answer.
Can u kindly explain me these three steps

T = t(2)-t(1);
fs = 1/T;
f = fs/2*linspace(-1,1,number_of_samples);

Why we are using these and does this rule hold good for every frequency. even for 10000 HZ thanks a lot.
 

In reality, Matlab is not performing a true fourier transform. Rather, it is performing a discrete fourier transform.

In order to unambiguously measure a frequency, you must take at least two samples per period. This means that my sampling rate limits how high a frequency I can measure.

The maximum frequency is just 1/2 my sampling rate.

This is an intrinsic limitation to DFTs. It is true for any frequency range. In order to properly measure high frequencies, you just have to increase your sampling rate to twice the highest frequency you expect to measure.

fs is the sampling frequency of this time series. I divide by two and that sets the frequency range.
 

Re: Frequency domain representation of time domain signal(Ma

thanks a lot for again detailed answer. you are really good in matlab and communication.
One last thing i could not understand the requirement of fftshift.
What is its main function.If you kindly explain me. Thanks
 

Re: Frequency domain representation of time domain signal(Ma

In the last portion of my project Bandpass modulation i have to do this step

(iii) performance comparison of simulated curve vs. theoretical curve along with time and freq. domain representation of the signals....

Can u Guide me for this step and refer some reading material.


When i asked my instructor abt frequency domian analysis he told me

By freq domain analysis...baseband signal freq response should be seen in frequency around Zero...and upconverted signal around the carrier freq

Can u give its example
 

When Matlab calculates the FFT, arranges the frequency axis with f=0 (i.e. DC component) as the start point.

We are used to seeing DC as the center of the graph, so all fftshift does is swap the left and right halfs of the data so that the zero frequency part is in the middle.

This is good to keep in mind if you are ever calculating the ifft (inverse Fourier transform), because the way Matlab wants the input data is not the same way you are used to.

Here is an example of looking at an Amplitude-Modulated signal. Hopefully it can get you started on working with other types of modulation.


%---------------------------------------
close all
%Set my sampling frequency
fs = 2^15;

%define one second in time sampled every fs
t = linspace(0, 1, fs);

%define datarate (how many bits/second)
datarate = 2^6;


%Baseband signal
binOne = ones(1, fs/datarate);
binZero = zeros(1,fs/datarate);

%I am sending ascii for '$$$$$$$$' to show how much money we will all be making as
%engineers
asciiDollarSign = ([binZero binZero binOne binZero binZero binOne binZero binZero]);
basebandsignal = repmat(asciiDollarSign, 1, 8 );

%BASEBAND ANALYSIS--------------------------------------------------------
figure
plot(t, basebandsignal);
title('This is what the baseband signal looks like')
xlabel('time (sec)');
ylabel('amplitude (v)');
axis([0 1 -.5 1.5]);

f = fs/2*linspace(-1, 1, fs);

basebandFFT = fftshift(fft(basebandsignal));
figure
plot(f, abs(basebandFFT));
title('Frequency content of Baseband Signal');
xlabel('Frequency (Hz)');
ylabel('Magnitude');
%--------------------------------------------------------------------------


%CARRIER FREQUENCY ANALYSIS------------------------------------------------

%Now create our mudulated signal
carrierFreq = 2^12;

carrierWave = cos(2*pi*carrierFreq*t);

%Amplitude modulation
modulatedsignal = carrierWave.*basebandsignal;

figure
plot(t, modulatedsignal);
title('Amplitude modulated signal');
xlabel('time (sec)');

%Find frequency content
modulatedsignalFFT = fftshift(fft(modulatedsignal));

figure
plot(f, abs(modulatedsignalFFT));
title('Frequency content of Amplitude Modulated Signal');
xlabel('Frequency (Hz)');
ylabel('Magnitude');
%--------------------------------------------------------------------------
 

Re: Frequency domain representation of time domain signal(Ma

hi,
thank you for attention,
I've written a code for FFT with data window. magnitude of response is very high.
I've attached my code . Please you find my mistake.
my signal is a non-stationary waves.

clc
Fs = 1e8;
fftLength = 5000;
% Calculates windowed FFT (length fftlen, with 50% overlap),
% then inverse FFT with overlap-add. If no processing is inserted
% into the function below, the output should be essentially identical
% to the input.
in=in:));
% Create output buffer for overlap add
xx=zeros(1,length(in));
% Create length “fftlen” raised cosine window function
wind=0.5*(1-cos(2*pi*(0:fftLength-1)/fftLength));
for i=1:fftLength/2:(length(in)-fftLength)
ff=fft(wind.*in(i:(i+fftLength-1))',fftLength);
z=abs(ff);
xx(i:(i+fftLength-1))= xx(i:(i+fftLength-1))+ ifft(ff,fftLength);
end
figure
semilogx([0:fftLength-1]*Fs/fftLength,abs(ff))
figure
plot(xx)
 

Re: Frequency domain representation of time domain signal(Ma

AndyECE i have sent u message in PM
kindly read it thanks
 

Guys - Nothing personal, but I'm not interested in PMing each other. I am here to contribute to the forum by helping introduce you to signal processing in Matlab in a practical way.

I am not here to have you email me code to debug.


Do you guys have a link to a reference for what you are trying to implement? It is difficult to look at code when you aren't positive what's supposed to happen
 

Re: Frequency domain representation of time domain signal(Ma

AndyECE said:
Guys - Nothing personal, but I'm not interested in PMing each other. I am here to contribute to the forum by helping introduce you to signal processing in Matlab in a practical way.

I am not here to have you email me code to debug.


Do you guys have a link to a reference for what you are trying to implement? It is difficult to look at code when you aren't positive what's supposed to happen

I agree, I also get LOTS of PMs. After replyin to some, I have learned to ignore rest
 

Hello;
I'm looking for a matlab code to transfer data from frequency domain to time domain.
ello;
I've not a function but I have measures as (frequency (3 GHz to 10 GHz), amplitude (dB) and phase) and I wanted to get, as from these data, Power (mW) versus delay (ns).
I need your help, I am a beginner in Matlab
Best Regards


Best Regards
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top