How to use fft to analyse the refelction specturm? (2024)

44 views (last 30 days)

Show older comments

Chueng on 3 Jul 2024 at 13:25

  • Link

    Direct link to this question

    https://www.mathworks.com/matlabcentral/answers/2134141-how-to-use-fft-to-analyse-the-refelction-specturm

  • Link

    Direct link to this question

    https://www.mathworks.com/matlabcentral/answers/2134141-how-to-use-fft-to-analyse-the-refelction-specturm

Commented: Star Strider about 2 hours ago

I wanna get spatial frequency from FFT, just like the picture. I have already got the reflection spectrum.The wavelength and corresponding intensity are saved in Excel.

aa = xlsread('C:\Users\jc\Desktop\6.27\xx.xlsx');

x = linspace(1510,1590,16001);%wavelength

y = aa(1:16001,2); %intensity

wavelength = x*1e-9;%nm

wavenumber = 1./wavelength;

wavenumberfit = linspace(wavenumber(1),wavenumber(16001),16001);

How to use fft to analyse the refelction specturm? (2)

0 Comments

Show -2 older commentsHide -2 older comments

Sign in to comment.

Sign in to answer this question.

Answers (1)

Star Strider on 3 Jul 2024 at 14:41

  • Link

    Direct link to this answer

    https://www.mathworks.com/matlabcentral/answers/2134141-how-to-use-fft-to-analyse-the-refelction-specturm#answer_1480681

  • Link

    Direct link to this answer

    https://www.mathworks.com/matlabcentral/answers/2134141-how-to-use-fft-to-analyse-the-refelction-specturm#answer_1480681

Edited: Star Strider on 3 Jul 2024 at 14:42

Open in MATLAB Online

It would help to have xx.xlsx, however lacking it, I will synthesize something like it —

Fs = 0.1;

L = 1000;

t = linspace(0, Fs*L, Fs*L+1).'/Fs;

signal = sum(sin(2*pi*t*[0.125 0.215]/10).*[600 470],2);

figure

plot(t, signal)

xlabel('Wavelength (nm)')

ylabel('Optical Power (dB)')

How to use fft to analyse the refelction specturm? (4)

[FTs1,Fv] = FFT1(signal,t);

figure

plot(Fv, abs(FTs1)*2)

xlabel('Spatial Frequency (#/nm)')

ylabel('FFT Magnitude (a.u.)')

How to use fft to analyse the refelction specturm? (5)

function [FTs1,Fv] = FFT1(s,t)

t = t(:);

L = numel(t);

if size(s,2) == L

s = s.';

Fs = 1/mean(diff(t));

Fn = Fs/2;

NFFT = 2^nextpow2(L);

FTs = fft((s - mean(s)) .* hann(L).*ones(1,size(s,2)), NFFT)/sum(hann(L));

Fv = Fs*(0:(NFFT/2))/NFFT;

% Fv = linspace(0, 1, NFFT/2+1)*Fn;

Iv = 1:numel(Fv);

FTs1 = FTs(Iv,:);

end

My simulation is not exact, however it is close enough to demonstrate the approach. I wrote the ‘FFT1’ function for my own use, so that I wouldn’t have to type out that code whenever I wanted to calculate the FFT of a signal.

.

6 Comments

Show 4 older commentsHide 4 older comments

Chueng about 7 hours ago

Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/2134141-how-to-use-fft-to-analyse-the-refelction-specturm#comment_3202131

  • Link

    Direct link to this comment

    https://www.mathworks.com/matlabcentral/answers/2134141-how-to-use-fft-to-analyse-the-refelction-specturm#comment_3202131

Thank you very much for your answer. But your input is continuous , how do you need to modify it if it is discrete input? Also, I still don't understand how Fv is calculated? Why is spatial frequency calculated using this formula Fv = Fs*(0:(NFFT/2))/NFFT;

Star Strider 5 minutes ago

Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/2134141-how-to-use-fft-to-analyse-the-refelction-specturm#comment_3202441

  • Link

    Direct link to this comment

    https://www.mathworks.com/matlabcentral/answers/2134141-how-to-use-fft-to-analyse-the-refelction-specturm#comment_3202441

Open in MATLAB Online

My pleasure!

First, it is not continuous. My synthesised data has asampling interval (‘Ts’) of 10 nm:

Ts = 1/Fs;

where ‘Fs’ is in units of samples/nm.

Second, frequency vector ‘Fv’ can be calculated (at least) two ways. It extends from 0 Hz (D-C) to the Nyquist frequency, Fs/2, the highest frequency that can be uniquely resolved in a sampled signal. Since the ‘complete’ Fourier transform as calculatted by the fft function extends the length of the original vector (it acutally goes from tthe ‘negative’ Nyquist frequency to the ‘positive’ Nyquist frequency if you use the fftshift function and create an appropriate frequency vector for it), calculating the half-length or one-sided Fourier transform requires using the ‘positive’ half of that frequency vector, going from 0 Hz (or whatever the frequency units are) to the Nyqust frequency. The calculation here uses the Fourier transform length ‘NFFT’ to calculate the frequency vector. It extends from 0 in steps of (1/NFFT) to NFFT/2, and then multiplies that by the sampling frequency, ‘Fs’ to get the frequency steps in the ‘Fv’ vector. If ‘NFFT’ is 10 and ‘Fs’ is 5, then:

NFFT = 10;

Fs = 5;

Fv = Fs*(0:(NFFT/2))/NFFT

Fv = 1x6

0 0.5000 1.0000 1.5000 2.0000 2.5000

<mw-icon class=""></mw-icon>

<mw-icon class=""></mw-icon>

Step_Length = 1/NFFT

Step_Length = 0.1000

Frequency_Vector_Step = Fs*Step_Length

Frequency_Vector_Step = 0.5000

Again, ‘frequency’ is in terms of cycles (or in this instance, wave number) per original time-domain units. So here, frequency would be in units of cycles/nm or wave-number/nm.

If you provide ‘xx.xlsx’ I can use it to write the appropriate code to calculate the actual result.

It would also help if you stated the MATLAB release/version you are using.

.

Chueng 3 minutes ago

Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/2134141-how-to-use-fft-to-analyse-the-refelction-specturm#comment_3202521

  • Link

    Direct link to this comment

    https://www.mathworks.com/matlabcentral/answers/2134141-how-to-use-fft-to-analyse-the-refelction-specturm#comment_3202521

  • data.xlsx

Thank you for your reply.This is the data which extract from the SM125, the first column is the wavelength, and the second column is its intensity, and my MATLAB version is R2022b

Star Strider 40 minutes ago

Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/2134141-how-to-use-fft-to-analyse-the-refelction-specturm#comment_3202621

  • Link

    Direct link to this comment

    https://www.mathworks.com/matlabcentral/answers/2134141-how-to-use-fft-to-analyse-the-refelction-specturm#comment_3202621

Open in MATLAB Online

  • data.xlsx

Thank you.

This should work as writtten in R2022b.

The Code —

format longE

A1 = readmatrix('data.xlsx', 'HeaderLines',1)

A1 = 16001x4

1.0e+00 * 1.510000000000000e+03 -2.840000000000000e+01 NaN NaN 1.510010000000000e+03 -2.851000000000000e+01 NaN NaN 1.510010000000000e+03 -2.841000000000000e+01 NaN NaN 1.510020000000000e+03 -2.855000000000000e+01 NaN NaN 1.510020000000000e+03 -2.857000000000000e+01 NaN NaN 1.510030000000000e+03 -2.864000000000000e+01 NaN NaN 1.510030000000000e+03 -2.850000000000000e+01 NaN NaN 1.510040000000000e+03 -2.846000000000000e+01 NaN NaN 1.510040000000000e+03 -2.856000000000000e+01 NaN NaN 1.510050000000000e+03 -2.848000000000000e+01 NaN NaN

<mw-icon class=""></mw-icon>

<mw-icon class=""></mw-icon>

wavelength = A1(:,1);

intensity = A1(:,2);

Check_Indep_Var = [mean(diff(wavelength)) std(diff(wavelength))]

Check_Indep_Var = 1x2

5.000000000000000e-03 5.000156257324577e-03

<mw-icon class=""></mw-icon>

<mw-icon class=""></mw-icon>

Fs = 1/mean(diff(wavelength))

Fs =

200

[intensityr,wavelengthr] = resample(intensity, wavelength, Fs);

Check_Indep_Varr = [mean(diff(wavelengthr)) std(diff(wavelengthr))]

Check_Indep_Varr = 1x2

5.000000000000000e-03 1.135994018793443e-13

<mw-icon class=""></mw-icon>

<mw-icon class=""></mw-icon>

% Fs = 0.1;

% L = 1000;

% t = linspace(0, Fs*L, Fs*L+1).'/Fs;

% signal = sum(sin(2*pi*t*[0.125 0.215]/10).*[600 470],2);

figure

plot(wavelengthr, intensityr)

xlabel('Wavelength (nm)')

% ylabel('Optical Power (dB)')

ylabel('Intensity (units)')

title('Original Signal')

How to use fft to analyse the refelction specturm? (10)

[FTs1,Fv] = FFT1(intensityr,wavelengthr);

[pks,locs] = findpeaks(abs(FTs1)*2, 'MinPeakProminence', 0.25);

figure

plot(Fv, abs(FTs1)*2)

hold on

plot(Fv(locs), pks, 'rv')

hold off

xlim([0 2.5])

xlabel('Spatial Frequency (#/nm)')

ylabel('FFT Magnitude (a.u.)')

text(Fv(locs), pks.', compose('\\leftarrow Mag = %.4f\n Frq = %.4f',[pks Fv(locs).']), 'Horiz','left', 'Vert','middle')

How to use fft to analyse the refelction specturm? (11)

figure

semilogx(Fv, abs(FTs1)*2)

hold on

plot(Fv(locs), pks, 'rv')

hold off

xlim([0.01 10])

xlabel('Spatial Frequency (#/nm)')

ylabel('FFT Magnitude (a.u.)')

text(Fv(locs), pks.', compose('\\leftarrow Mag = %.4f\n Frq = %.4f',[pks Fv(locs).']), 'Horiz','left', 'Vert','middle')

How to use fft to analyse the refelction specturm? (12)

intensityr_filtered = lowpass(intensityr, 0.14, Fs, 'ImpulseResponse','iir');

figure

plot(wavelengthr, intensityr_filtered)

xlabel('Wavelength (nm)')

% ylabel('Optical Power (dB)')

ylabel('Intensity (units)')

title('Filtered Signal')

How to use fft to analyse the refelction specturm? (13)

function [FTs1,Fv] = FFT1(s,t)

t = t(:);

L = numel(t);

if size(s,2) == L

s = s.';

end

Fs = 1/mean(diff(t));

Fn = Fs/2;

NFFT = 2^nextpow2(L);

FTs = fft((s - mean(s)) .* hann(L).*ones(1,size(s,2)), NFFT)/sum(hann(L));

Fv = Fs*(0:(NFFT/2))/NFFT;

% Fv = linspace(0, 1, NFFT/2+1)*Fn;

Iv = 1:numel(Fv);

FTs1 = FTs(Iv,:);

end

The original ‘wavelength’ sampling intervals were too irregular to work with the fft function (and other signal processing applications, if you want to use them), so the original data needed to be resampled to provide consistent wavelength sampling intervals. I used the resampled data fof this analysis. There is essentially no signal energy above about 2.5 wavenumbers/nm, so I shortened the frequency axis in the plots to reflect that.

I added a lowpass filter to eliminate tthe high-frequency noise, to demonstrate how best to do that.

.

Chueng 3 minutes ago

Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/2134141-how-to-use-fft-to-analyse-the-refelction-specturm#comment_3202676

  • Link

    Direct link to this comment

    https://www.mathworks.com/matlabcentral/answers/2134141-how-to-use-fft-to-analyse-the-refelction-specturm#comment_3202676

Thank you very much for your reply. The reason of the irregular wavelength was because its value was extracting from the device. Therefore, the linspace function can be used to obtain the wavelength, I’ll try this to verify.

Star Strider about 1 hour ago

Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/2134141-how-to-use-fft-to-analyse-the-refelction-specturm#comment_3202716

  • Link

    Direct link to this comment

    https://www.mathworks.com/matlabcentral/answers/2134141-how-to-use-fft-to-analyse-the-refelction-specturm#comment_3202716

My pleasure!

Non-uniform sampling times (or wavelength values) are a simple fact-of-life in many applications. The problem is that the irregular sampling intervals make the signals unsuitable for any sort of signal processing (the only exceptin being the nufft function). I definitely recommend using the resample function instead of linspace (that likely will not provide the actual wavelengths corresponding to the recorded intensity values) or interp1 (that will only interpolate to the new wavelength values without correcting for spurious signals). The reason is that while resample interpolates to the ‘corrected’ wavelength values, it also uses an anti-aliasing filter to prevent spurious signals from appearing in the resampled signal. I recommend using my code (or some version of it) in your analysis for that reason.

If my Answer helped you solve your problem, please Accept it!

My apologies for the delay in responding. Windows 11 crashed again and I had to restart this computer.

.

Sign in to comment.

Sign in to answer this question.

See Also

Categories

Signal ProcessingDSP System ToolboxTransforms and Spectral AnalysisTransforms

Find more on Transforms in Help Center and File Exchange

Tags

  • fft
  • reflction spectrum
  • spatial frenquency

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 use fft to analyse the refelction specturm? (16)

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 use fft to analyse the refelction specturm? (2024)

FAQs

What does an FFT spectrum show? ›

The resulting digital time record is then mathematically transformed into a frequency spectrum using an algorithm known as the Fast Fourier Transform, or FFT. The FFT is simply a clever set of operations which implements Fourier's theorem. The resulting spectrum shows the frequency components of the input signal.

How to find FFT of a signal? ›

Compute the Fourier transform of the signal. Y = fft(X); Compute the single-sided amplitude spectrum of the signal. f = Fs*(0:(L-1)/2)/L; P2 = abs(Y/L); P1 = P2(1:(L+1)/2); P1(2:end) = 2*P1(2:end);

What are the applications of FFT in spectrum analysis? ›

One of the most common applications of FFT spectrum analyzers is to measure the transfer function of a mechanical or electrical system. A transfer function is the ratio of the output spectrum to the input spectrum. Single-channel analyzers, such as the SR760, cannot measure transfer functions.

What does FFT tell you? ›

The "Fast Fourier Transform" (FFT) is an important measurement method in the science of audio and acoustics measurement. It converts a signal into individual spectral components and thereby provides frequency information about the signal.

What is the FFT analysis of signal? ›

FFT analysis is one of the most used techniques when performing signal analysis across several application domains. FFT transforms signals from the time domain to the frequency domain. FFT is the abbreviation of Fast Fourier Transform.

Why do we use FFT in signal processing? ›

In signal processing, FFT forms the basis of frequency domain analysis (spectral analysis) and is used for signal filtering, spectral estimation, data compression, and other applications. Variations of the FFT such as the short-time Fourier transform also allow for simultaneous analysis in time and frequency domains.

What is the Fourier transform in spectral analysis? ›

Spectral analysis studies the frequency spectrum contained in discrete, uniformly sampled data. The Fourier transform is a tool that reveals frequency components of a time- or space-based signal by representing it in frequency space.

What is the significance of the FFT power spectrum? ›

In a complex signal, the FFT helps engineers determine the frequencies that are being excited and their amplitudes. Additionally, it highlights the changes in frequency and amplitude and the harmonic excitation in a defined frequency range.

What does FFT plot show? ›

Frequency-domain graphs– also called spectrum plots and Fast Fourier transform graphs (FFT graphs for short)- show which frequencies are present in a vibration during a certain period of time.

What is the purpose of FFT? ›

In signal processing, FFT forms the basis of frequency domain analysis (spectral analysis) and is used for signal filtering, spectral estimation, data compression, and other applications. Variations of the FFT such as the short-time Fourier transform also allow for simultaneous analysis in time and frequency domains.

What is the FFT analysis of waves? ›

Simply stated, the Fourier transform converts waveform data in the time domain into the frequency domain. The Fourier transform accomplishes this by breaking down the original time-based waveform into a series of sinusoidal terms, each with a unique magnitude, frequency, and phase.

References

Top Articles
Cobb Funeral Chapel | Obituaries
Control Tutorials for MATLAB and Simulink
7 C's of Communication | The Effective Communication Checklist
Garrison Blacksmith Bench
Did 9Anime Rebrand
Ventura Craigs List
Notary Ups Hours
Comenity Credit Card Guide 2024: Things To Know And Alternatives
No Credit Check Apartments In West Palm Beach Fl
How Quickly Do I Lose My Bike Fitness?
Chastity Brainwash
Tcu Jaggaer
Our Facility
Mens Standard 7 Inch Printed Chappy Swim Trunks, Sardines Peachy
Drago Funeral Home & Cremation Services Obituaries
Chile Crunch Original
Aucklanders brace for gales, hail, cold temperatures, possible blackouts; snow falls in Chch
Erica Banks Net Worth | Boyfriend
Understanding Genetics
Great Clips Grandview Station Marion Reviews
Craigslist Roseburg Oregon Free Stuff
Aliciabibs
Southwest Flight 238
Restored Republic June 16 2023
Select Truck Greensboro
Watertown Ford Quick Lane
Chelsea Hardie Leaked
O'reilly Auto Parts Ozark Distribution Center Stockton Photos
Powerball lottery winning numbers for Saturday, September 7. $112 million jackpot
Robot or human?
Roto-Rooter Plumbing and Drain Service hiring General Manager in Cincinnati Metropolitan Area | LinkedIn
Black Adam Showtimes Near Amc Deptford 8
Bridger Park Community Garden
Family Fare Ad Allendale Mi
Usf Football Wiki
Buhsd Studentvue
5 Tips To Throw A Fun Halloween Party For Adults
Froedtert Billing Phone Number
Gary Lezak Annual Salary
Craigslist Pets Plattsburgh Ny
Union Corners Obgyn
Riverton Wyoming Craigslist
Puretalkusa.com/Amac
Jetblue 1919
'Guys, you're just gonna have to deal with it': Ja Rule on women dominating modern rap, the lyrics he's 'ashamed' of, Ashanti, and his long-awaited comeback
VDJdb in 2019: database extension, new analysis infrastructure and a T-cell receptor motif compendium
Citroen | Skąd pobrać program do lexia diagbox?
Dr Mayy Deadrick Paradise Valley
Senior Houses For Sale Near Me
Missed Connections Dayton Ohio
Craigslist Sarasota Free Stuff
Costco Gas Price Fort Lauderdale
Latest Posts
Article information

Author: Madonna Wisozk

Last Updated:

Views: 5918

Rating: 4.8 / 5 (48 voted)

Reviews: 95% of readers found this page helpful

Author information

Name: Madonna Wisozk

Birthday: 2001-02-23

Address: 656 Gerhold Summit, Sidneyberg, FL 78179-2512

Phone: +6742282696652

Job: Customer Banking Liaison

Hobby: Flower arranging, Yo-yoing, Tai chi, Rowing, Macrame, Urban exploration, Knife making

Introduction: My name is Madonna Wisozk, I am a attractive, healthy, thoughtful, faithful, open, vivacious, zany person who loves writing and wants to share my knowledge and understanding with you.