How can i get main wave from frequency data?

6 Ansichten (letzte 30 Tage)
tst
tst am 1 Feb. 2023
Bearbeitet: Abhishek am 30 Mai 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 Kommentar
Image Analyst
Image Analyst am 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:

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Abhishek
Abhishek am 29 Mai 2025
Bearbeitet: Abhishek am 30 Mai 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!

Kategorien

Mehr zu Fourier Analysis and Filtering finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by