How can i get main wave from frequency data?

6 views (last 30 days)
tst
tst on 1 Feb 2023
Edited: Abhishek on 30 May 2025
I want to get: 1-get frequency of wave or signal whit fft. 2- create sin waves and sum them from frequency data, to create wave like main wave;
this is my code but its not work.
  1 Comment
Image Analyst
Image Analyst on 1 Feb 2023
We can't run an image and no one is going to type all that in.
In general you can take the fft to see the power at different frequencies. You can look for spikes for particularly strong frequencies. So identify the peak. You can then zero out everything else and inverse transform. Or just take the known frequency of the peak and reconstruct a perfect, noise free signal knowing that frequency.
If you have any more questions, then attach your data and code to read it in ("tst'm") with the paperclip icon after you read this:

Sign in to comment.

Answers (1)

Abhishek
Abhishek on 29 May 2025
Edited: Abhishek on 30 May 2025
Hi @tst,
I understand that you want to extract the frequency components of a signal using the Fast Fourier Transform (FFT) and reconstruct the original signal using the identified frequencies.
There is a minor issue in the function “ftosin” and a suggested improvement:
  • When using the “findpeaks” function to identify significant frequency components, it is important to filter out noise and minor fluctuations. This can be achieved by applying a threshold using the “MinPeakHeight” parameter as shown below:
[f_a, f_b] = findpeaks(dt, "MinPeakHeight", max(dt)*0.25);
Here, 0.25 is an arbitrary threshold that retains peaks with amplitudes at least 25% of the maximum peak. This ensures that only significant frequency components contribute to the reconstructed signal, resulting in closer approximation of the original (noise-free) signal “S”.
  • Instead of initializing variable “f_sn” with a sine wave and subtracting it at the end, it can be initialized with zeros.
By making the above modifications, the function “ftosin” can be re-written as:
function func=ftosin(dt,Fs,L)
[f_a, f_b] = findpeaks(dt,"MinPeakHeight",max(dt)*0.25);
f_t = (1:1500)*2*pi*0.001;
f_sn = zeros(size(f_t));
f_b = (f_b-1).*Fs/L;
for i=1:length(f_a)
f_crt = f_a(i)*sin(f_b(i)*f_t);
f_sn = f_sn+f_crt;
end
func = f_sn;
end
To learn more about “findpeaks” function and its available parameters, please refer to the below documentation:
I hope this resolves your query!

Categories

Find more on Fourier Analysis and Filtering in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!