Function aproximation with exp functions

조회 수: 4 (최근 30일)
Dominik Vana
Dominik Vana 2019년 12월 22일
댓글: J. Alex Lee 2019년 12월 23일
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