Function that fits a wave

6 次查看(过去 30 天)
Rowan Humphreys
Rowan Humphreys 2022-6-17
I need to create a function that describes an audio wave. I have tried the fit() function with sine and gaussian but they don't have sufficient detail. Can you recomend me some technique that generates a function that more accurately describes this wave?
The following is my code:
clear all;
[y,Fs] = audioread('raindrop.wav');
sound(y,Fs);
x = (1:1:length(y))';
f = fit(x,y,'gauss8');
C = coeffvalues(f);
plot(f,x,y)
%the following shows me just the fit
F = C(01)*exp(-((x-C(02))/C(03)).^2) + C(04)*exp(-((x-C(05))/C(06)).^2) + ...
C(07)*exp(-((x-C(08))/C(09)).^2) + C(10)*exp(-((x-C(11))/C(12)).^2) + ...
C(13)*exp(-((x-C(14))/C(15)).^2) + C(16)*exp(-((x-C(17))/C(18)).^2) + ...
C(19)*exp(-((x-C(20))/C(21)).^2) + C(22)*exp(-((x-C(23))/C(24)).^2);
plot(x,F)
sound(F,Fs)

回答(1 个)

Pooja Kumari
Pooja Kumari 2023-9-27
编辑:Pooja Kumari 2024-1-10
Dear Rowan,
It is my understanding that you are facing issue with creating a function to describe an audio wave with more detail than a simple sine or Gaussian function. I am assuming that you want to learn more about how to describe an audio wave. You can consider any of the below approach for describing an audio wave:
You can also examine and comprehend the properties of the audio wave more thoroughly by making an app. You can refer to the below example on how to create an app to play and visualize audio file:
  • Using Fourier analysis of audio signal: Performing a Fourier analysis on an audio signal involves applying a Fourier transform, such as the Fast Fourier Transform (FFT), to move the audio wave from the time domain to the frequency domain. This will give the amplitude and phase information for each frequency component present in the audio wave. You can refer to the documentation below for more information: https://www.mathworks.com/help/matlab/ref/fft.html
Regards,
Pooja Kumari

类别

Help CenterFile Exchange 中查找有关 Simulation, Tuning, and Visualization 的更多信息

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by