Function aproximation with exp functions

4 次查看(过去 30 天)
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

回答(1 个)

Star Strider
Star Strider 2019-12-22
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 个评论
J. Alex Lee
J. Alex Lee 2019-12-23
if that doesn't work, instead of adding a sinusoid try multiplying by a sigmoid like logistic or tanh()

请先登录,再进行评论。

Community Treasure Hunt

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

Start Hunting!

Translated by