Function aproximation with exp functions
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello,
I am working on my master thesis. My supervisor wants me to do aproximation of fuctions on pictures below without using polyfit. He wants to find simplest fuctions possible. I think fuctions are some kind of exponential functions.
Is there anybody who has experiences with these functions?
Thank you.
DV
On these pictures I am using polyfit.

0 commentaires
Réponses (1)
Star Strider
le 22 Déc 2019
Try this:
t = linspace(-40, 40, 35);
s1 = sinc(t/10);
s2 = exp(-t.^2/20);
objfcn = @(b,t) b(1).*exp(-b(2)*t.^2) + b(3).*sin(b(4).*t+b(5));
s1prm = fminsearch(@(b) norm(s1 - objfcn(b,t)), rand(5,1)*10)
s2prm = fminsearch(@(b) norm(s2 - objfcn(b,t)), rand(5,1)*10)
figure
plot(t, s1, 'rp', t, s2, 'gp')
hold on
plot(t, objfcn(s1prm,t), '--r')
plot(t, objfcn(s2prm,t), '--g')
hold off
grid
The ‘objfcn’ function is a combination of a sinusoid and a Gaussian. The regression parameters alloow it to fit both kinds of functions reasonablly well.
Experiment to get different (and perhaps better) results. Anoather option of course is to use the fft function to create a Fourier transform of the original waveform, then use a select subset of the Fourier coefficients to reconstruct it.
1 commentaire
J. Alex Lee
le 23 Déc 2019
if that doesn't work, instead of adding a sinusoid try multiplying by a sigmoid like logistic or tanh()
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!