필터 지우기
필터 지우기

genetic algorithm for curve fitting

조회 수: 20 (최근 30일)
Emran Alotaibi
Emran Alotaibi 2020년 11월 8일
댓글: Divya Thokala 2021년 5월 10일
I know this question have been extensively asked previously,
However, I want to fit an exponontial equation y = a*(1-b*exp(-c*x)) where a,b and c are constants to be optimized, y and x are experimental data obtained as follows
xx=[0.001,5,10,20,40,80];
yy=[0,5,8,11.2,18.3,25.3];
From previous threads I read in the fourm, I ended up forming the below function:
function x = material(y)
xx=[0.001,5,10,20,40,80];
yy=[0,5,8,11.2,18.3,25.3];
a=y(1); b=y(2); c=y(3);
for j=1:6
x=(a)*(1-b*exp(-c*xx(j)))-yy(j);
end
end
I used the function above with GA toolbox in MATLAB 2017b, the results are way wrong
49.98723904071618 49.939937193013776 0.011881054853272788 for a,b and c respictevely
what i have missed?
Thanks for your help!

채택된 답변

Ameer Hamza
Ameer Hamza 2020년 11월 8일
Try this
xx=[0.001,5,10,20,40,80];
yy=[0,5,8,11.2,18.3,25.3];
fun = @(p) p(1)*(1-p(2)*exp(-p(3)*xx));
objFun = @(p) norm(fun(p)-yy);
sol = ga(objFun, 3);
figure()
axes();
plot(xx, yy, 'b+');
hold on
plot(xx, fun(sol), 'r-');
legend({'Data points', 'Fitted Curve'})
  댓글 수: 3
Ameer Hamza
Ameer Hamza 2020년 11월 8일
I am glad to be of help! :)
Divya Thokala
Divya Thokala 2021년 5월 10일
I have ran a code similar to this. Actually I am not aware of how to optimize it. My graph is coming like slopy as in the figure shown. please help me
xx=xlsread('wave.xlsx','A:A');
yy=xlsread('wave.xlsx','B:B');
fun = @(p) p(1)+p(2)*cos(2*3.14*xx/12)+p(3)*sin(2*3.14*xx/12)+p(4)*xx;
objFun = @(p) norm(fun(p)-yy);
sol = ga(objFun, 4);
figure()
axes();
plot(xx, yy, 'b+');
hold on
plot(xx, fun(sol), 'r-');
legend({'Data points', 'Fitted Curve'})

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Genetic Algorithm에 대해 자세히 알아보기

제품


릴리스

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by