Function aproximation with exp functions

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.
problem_2.JPG problem_1.JPG

Risposte (1)

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 Commento

if that doesn't work, instead of adding a sinusoid try multiplying by a sigmoid like logistic or tanh()

Accedi per commentare.

Richiesto:

il 22 Dic 2019

Commentato:

il 23 Dic 2019

Community Treasure Hunt

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

Start Hunting!

Translated by