How to scale the plot of an Inverse Fast Fourier Transform? (2024)

2 views (last 30 days)

Show older comments

Joe on 6 Jul 2013

  • Link

    Direct link to this question

    https://support.mathworks.com/matlabcentral/answers/81275-how-to-scale-the-plot-of-an-inverse-fast-fourier-transform

  • Link

    Direct link to this question

    https://support.mathworks.com/matlabcentral/answers/81275-how-to-scale-the-plot-of-an-inverse-fast-fourier-transform

Accepted Answer: Matt J

Open in MATLAB Online

Hi, I'm not sure how to get my scaling right in my ifft from frequency to time when I plot it. I've tried below, but I know something is off from the graph. Thanks.

% Constants

c = 299792458; % speed of light in a vacuum

FWHM = 30e-15; % pulse duration

T = FWHM/(2*(sqrt(log(2)))); % (T=tau)

lambda0 = 800e-9; % central wavelength

w0 = (2*pi*c)/lambda0; % central angular frequency

eta = 0; % chirp (2nd derivitive of phase)

% electric field and intensity in wavelength domain

nfft = 2^12;

lambda = (740e-9:((120e-9)/(nfft-1)):860e-9);

w = (2.*pi.*c)./lambda;

E_w = (1/(sqrt((1/T.^2)+i*eta)))*exp((-(w-w0).^2)/((2/T.^2)+2*i*eta));

I_lambda= (abs(E_w)).^2;

% IFFT

Fs = w/(2*pi); % sampling frequency

df = Fs/nfft;

dw = 2*pi*df;

dt = 1./Fs; % increments of time

T1 = (nfft*dt);

t = (-T1/2+dt:dt:T1/2);

ifftE_t = ifft(E_w); % ifft

% PLOT

subplot(2, 1, 1);

plot(w, I_lambda);

title('Gaussian Pulse Signal');

xlabel('Wavelength');

ylabel('I_\lambda');

subplot(2, 1, 2)

plot(t, abs(ifftE_t))

0 Comments

Show -2 older commentsHide -2 older comments

Sign in to comment.

Sign in to answer this question.

Accepted Answer

Matt J on 7 Jul 2013

  • Link

    Direct link to this answer

    https://support.mathworks.com/matlabcentral/answers/81275-how-to-scale-the-plot-of-an-inverse-fast-fourier-transform#answer_91063

  • Link

    Direct link to this answer

    https://support.mathworks.com/matlabcentral/answers/81275-how-to-scale-the-plot-of-an-inverse-fast-fourier-transform#answer_91063

Edited: Matt J on 7 Jul 2013

Open in MATLAB Online

The following modification seems to work for me. I get Gaussian-looking pulses in both the time and frequency domain, exactly as expected for eta=0.

% Constants

c = 299792458; % speed of light in a vacuum

FWHM = 30e-15; % pulse duration

T = FWHM/(2*(sqrt(log(2)))); % (T=tau)

lambda0 = 800e-9; % central wavelength

w0 = (2*pi*c)/lambda0; % central angular frequency

eta = 0; % chirp (2nd derivitive of phase)

% electric field and intensity in wavelength domain

f0=w0/(2*pi);

L=(1/FWHM); %order of magnitude of pulse duration in frequency space

df=L/10000;

Df=5*L; %frequency duration

N=ceil(Df/df);

dt=1/N/df;

NormalizedAxis= (0:N-1) -ceil((N-1)/2);

t=dt*NormalizedAxis;

f=df*NormalizedAxis;

w=2*pi*f;

dw=2*pi*df;

% Spectra

E_w = (1/(sqrt((1/T.^2)+1i*eta)))*exp((-(w).^2)/((2/T.^2)+2*1i*eta));

I_lambda= (abs(E_w)).^2;

% IFFT

ifftE_t = fftshift(ifft(E_w))/dt; % ifft

% PLOT

subplot(2, 1, 1);

plot(w+w0, I_lambda);

title('Gaussian Pulse Signal');

xlabel('Wavelength');

ylabel('I_\lambda');

subplot(2, 1, 2)

plot(t, abs(ifftE_t)); xlim(FWHM*[-5,5])

3 Comments

Show 1 older commentHide 1 older comment

Joe on 7 Jul 2013

Direct link to this comment

https://support.mathworks.com/matlabcentral/answers/81275-how-to-scale-the-plot-of-an-inverse-fast-fourier-transform#comment_158704

  • Link

    Direct link to this comment

    https://support.mathworks.com/matlabcentral/answers/81275-how-to-scale-the-plot-of-an-inverse-fast-fourier-transform#comment_158704

Open in MATLAB Online

Yes this seems to work. Just a few things...

Why does it not seem to effect the graphs at all when eta is adjusted?

Also, why in this line

E_w = (1/(sqrt((1/T.^2)+1i*eta)))*exp((-(w).^2)/((2/T.^2)+2*1i*eta));

is there 1i? is that just a mistake or...? and why did -(w-w0).^2 switch to just -(w).^2?

Sorry if it seems I'm badgering you with questions. I appreciate the help a lot.

Matt J on 7 Jul 2013

Direct link to this comment

https://support.mathworks.com/matlabcentral/answers/81275-how-to-scale-the-plot-of-an-inverse-fast-fourier-transform#comment_158711

  • Link

    Direct link to this comment

    https://support.mathworks.com/matlabcentral/answers/81275-how-to-scale-the-plot-of-an-inverse-fast-fourier-transform#comment_158711

Edited: Matt J on 7 Jul 2013

Open in MATLAB Online

Why does it not seem to effect the graphs at all when eta is adjusted?

I definitely see a change in I_lambda as eta is varied over 0, 1/T^2, 5/T^2.

abs(ifftE_t) seems to be invariant to eta for some reason, but real(ifftE_t) is not.

is there 1i? is that just a mistake or...?

It's the recommended way to express sqrt(-1). Supposedly, MATLAB processes it faster. It also allows you to use i as a variable without creating conflict, e.g.,

>> i=3; c=i+2i

c =

3.0000 + 2.0000i

why did -(w-w0).^2 switch to just -(w).^2?

Personal preference. A shift in frequency doesn't affect abs(ifftE_t), so it didn't matter.

Joe on 7 Jul 2013

Direct link to this comment

https://support.mathworks.com/matlabcentral/answers/81275-how-to-scale-the-plot-of-an-inverse-fast-fourier-transform#comment_158713

  • Link

    Direct link to this comment

    https://support.mathworks.com/matlabcentral/answers/81275-how-to-scale-the-plot-of-an-inverse-fast-fourier-transform#comment_158713

Thanks for your help. Much appreciated.

Sign in to comment.

More Answers (1)

Matt J on 6 Jul 2013

  • Link

    Direct link to this answer

    https://support.mathworks.com/matlabcentral/answers/81275-how-to-scale-the-plot-of-an-inverse-fast-fourier-transform#answer_90987

  • Link

    Direct link to this answer

    https://support.mathworks.com/matlabcentral/answers/81275-how-to-scale-the-plot-of-an-inverse-fast-fourier-transform#answer_90987

Edited: Matt J on 6 Jul 2013

Open in MATLAB Online

There is no standardized way of scaling Fourier transforms. Different professions scale it differently. If you are using the engineering profession's definition of the continuous inverse Fourier transform, you can approximate it as

ifft(X)/dt

where dt is the sampling interval in the time domain.

However, you have bigger problems in your code. Your sampling interval, dt, is a vector for some reason, instead of a scalar

>> size(dt)

ans =

1 4096

which among other things means that the following line doesn't make sense

t = (-T1/2+dt:dt:T1/2);

Colon operations a:b:c are meant to be done with scalar a,b,c.

3 Comments

Show 1 older commentHide 1 older comment

Joe on 7 Jul 2013

Direct link to this comment

https://support.mathworks.com/matlabcentral/answers/81275-how-to-scale-the-plot-of-an-inverse-fast-fourier-transform#comment_158654

  • Link

    Direct link to this comment

    https://support.mathworks.com/matlabcentral/answers/81275-how-to-scale-the-plot-of-an-inverse-fast-fourier-transform#comment_158654

Open in MATLAB Online

Ok so I think I have the right sampling interval dt. So I just don't understand how to get my sampling time from the sampling interval that I want to plot against.

Fs = w/(2*pi); % sampling frequency

dt = T/nfft;

t = (0:dt:(dt*length(E_w)));

ifftE_t = ifftshift(ifft(E_w))/dt; % ifft

Matt J on 7 Jul 2013

Direct link to this comment

https://support.mathworks.com/matlabcentral/answers/81275-how-to-scale-the-plot-of-an-inverse-fast-fourier-transform#comment_158673

  • Link

    Direct link to this comment

    https://support.mathworks.com/matlabcentral/answers/81275-how-to-scale-the-plot-of-an-inverse-fast-fourier-transform#comment_158673

Edited: Matt J on 7 Jul 2013

Open in MATLAB Online

You should probably also be doing the ifft as follows

ifftE_t = fftshift(ifft(ifftshift(E_w))/dt);

I still don't know why you have

Fs = w/(2*pi); % sampling frequency

Since w is a vector, your sampling frequency Fs will be a vector as well, which wouldn't make sense. I still also don't understand how you can generate w according to

w = (2.*pi.*c)./lambda;

since this will give you non-equispaced samples in w. You need to decide on a scalar dw first and then generate equi-spaced w, something like

N=nfft;

dw=mean(diff(2*pi*c./lambda)); %just an example dw

w=dw*(0:N-1) -ceil((N-1)/2);

Then for the time axis. you would do

dt=1/N/dw;

timeAxis=dt*( (0:N-1) -ceil((N-1)/2) );

Joe on 7 Jul 2013

Direct link to this comment

https://support.mathworks.com/matlabcentral/answers/81275-how-to-scale-the-plot-of-an-inverse-fast-fourier-transform#comment_158684

  • Link

    Direct link to this comment

    https://support.mathworks.com/matlabcentral/answers/81275-how-to-scale-the-plot-of-an-inverse-fast-fourier-transform#comment_158684

Open in MATLAB Online

That didn't really give me what I wanted I wanted a graph more like this:

df = w(1)/(2*pi) - w(2)/(2*pi);

ifftE_t = ifftshift(ifft(E_w))*df; % ifft

Ts = 1/df;

dt = Ts/length(E_w);

time = -Ts/2:dt:Ts/2-dt;

Except I'm not getting enough oscillations. That w that you had made my first graph a straight line

w=dw*(0:N-1) -ceil((N-1)/2);

Although you are right that my w that gives me non-equispaced samples so I'm not really sure how to fix that because when I adjust my w it doesn't give me the right graph.

I'm comparing this ifft to an equation I got when I did the math analytically here.

% (test to see if inverse fourier matches)

Pt = -100e-15:1e-15:100e-15;

PE_t =exp((-Pt.^2/(2*T.^2)) + (i*w0*Pt-(1/2)*i*eta*Pt.^2)); %*phi_t));

plot(Pt, PE_t);

Sorry if I don't make to much sense, this is my first time using MATLAB and working with Fourier Transformations.

Sign in to comment.

Sign in to answer this question.

See Also

Categories

Signal ProcessingSignal Processing ToolboxTransforms, Correlation, and ModelingTransformsHilbert and Walsh-Hadamard Transforms

Find more on Hilbert and Walsh-Hadamard Transforms in Help Center and File Exchange

Tags

  • ifft
  • scaling
  • plotting

Community Treasure Hunt

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

Start Hunting!

An Error Occurred

Unable to complete the action because of changes made to the page. Reload the page to see its updated state.


How to scale the plot of an Inverse Fast Fourier Transform? (10)

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list

Americas

  • América Latina (Español)
  • Canada (English)
  • United States (English)

Europe

  • Belgium (English)
  • Denmark (English)
  • Deutschland (Deutsch)
  • España (Español)
  • Finland (English)
  • France (Français)
  • Ireland (English)
  • Italia (Italiano)
  • Luxembourg (English)
  • Netherlands (English)
  • Norway (English)
  • Österreich (Deutsch)
  • Portugal (English)
  • Sweden (English)
  • Switzerland
    • Deutsch
    • English
    • Français
  • United Kingdom(English)

Asia Pacific

  • Australia (English)
  • India (English)
  • New Zealand (English)
  • 中国
  • 日本Japanese (日本語)
  • 한국Korean (한국어)

Contact your local office

How to scale the plot of an Inverse Fast Fourier Transform? (2024)
Top Articles
Robertsdale AL Single Family Homes For Sale - 67 Homes | Zillow
Robertsdale, AL Single Family Homes for Sale | realtor.com®
The Machine 2023 Showtimes Near Habersham Hills Cinemas
19 Awesome Things to Do in Redmond, Oregon
Gma Deals And Steals December 5 2022
Elektrisch koffiezetapparaat Philips CSA240/61 1450 W Zwart 1450 W | bol
Nj Scratch Off Remaining Prizes
North Carolina Houses For Rent Craigslist
Omniplex Cinema Dublin - Rathmines | Cinema Listings
Woman Jumps Off Mount Hope Bridge 2022
Steven Batash Md Pc Photos
Island Cremations And Funeral Home
Pierced Universe Coupon
Lowes Maytag Pet Pro Commercial Actress
Gran Turismo Showtimes Near Regal Crocker Park
Pachuvum Athbutha Vilakkum Movie Download Telegram Link
Saltburn | Rotten Tomatoes
How Much Is 7 Million Pesos
April 7 Final Jeopardy
Onderdelen | Onderdelen en services
Über 60 Prozent Rabatt auf E-Bikes: Aldi reduziert sämtliche Pedelecs stark im Preis - nur noch für kurze Zeit
Water Leaks in Your Car When It Rains? Common Causes & Fixes
Rockcastle County Schools Calendar
Walmart Phone Number Auto Center
How Much Does Costco Gas Cost Today? Snapshot of Prices Across the U.S. | CostContessa
Meritain Prior Authorization List
What to know about Canada and China's foreign interference row
Advance Auto.parts Near Me
June Month Weather
Megan Hall Bikini
Kleen Krete Concrete Remover 1 Gal Liquid 32110
Police in Germany arrest 25 people allegedly planning to overthrow the government
Holley Gamble Funeral Home In Clinton
Lehigh Wheelmen Meetup
Bank Of America Financial Center Irvington Photos
Where To Find Permit Validation Number
10000 Blaulicht-Meldungen aus Baden-Württemberg | Presseportal
Ups Near Me Open
Kostenlose Online-Spiele. Spielen Besten Kostenlosen Online-Spiele. Mobil, PC. Android, iOS
Horoscope Today: Astrological prediction September 9, 2024 for all zodiac signs
Abingdon Avon Skyward
Megan Bayne Has Made A Mega Mark Since Arriving In Stardom
Jodie Sweetin Breast Reduction
South Carolina Craigslist Motorcycles
Amariah Morales Snapchat
Craigslist Lasalle County Il
Hotels Near William Woollett Jr Aquatics Center
Art Labeling Activity The Big Picture Of Nutrient Catabolism — I Hate CBT's
Lhhouston Photos
Papitop
Find Such That The Following Matrix Is Singular.
Wiley Rein Vault
Latest Posts
Article information

Author: Dean Jakubowski Ret

Last Updated:

Views: 5590

Rating: 5 / 5 (70 voted)

Reviews: 93% of readers found this page helpful

Author information

Name: Dean Jakubowski Ret

Birthday: 1996-05-10

Address: Apt. 425 4346 Santiago Islands, Shariside, AK 38830-1874

Phone: +96313309894162

Job: Legacy Sales Designer

Hobby: Baseball, Wood carving, Candle making, Jigsaw puzzles, Lacemaking, Parkour, Drawing

Introduction: My name is Dean Jakubowski Ret, I am a enthusiastic, friendly, homely, handsome, zealous, brainy, elegant person who loves writing and wants to share my knowledge and understanding with you.