Problem with non-linear fit

조회 수: 1 (최근 30일)
R7 DR
R7 DR 2015년 10월 9일
댓글: Star Strider 2015년 10월 9일
Hi I am trying to fit the data and find the constant values. my code is...
[T]=xlsread('Matlab.xlsx','sheet2','C5:C2685')
[alpha]=xlsread('Matlab.xlsx','sheet2','I5:I2685')%time
[dalpha_dt]=xlsread('Matlab.xlsx','sheet2','J5:J2685')
F=ones(size(alpha));
F=(1-alpha)
coeff0=[2.17E+22, 5] % initial guess
coeff=nlinfit([T,F],dalpha_dt,@model,coeff0);
A=coeff(:,1)
n=coeff(:,2)
Function:
function dhat=model(coef,a)
% par_fit = [a b]
a=coef(1);
b=coef(2);
T=a(:,1);
F=a(:,2);
% predicted model
dhat=a.*exp(208000./(8.3147*(T+273))).*(F^b);
return
I need to find the new coefficient values, but it is showing following error..Please tell me how to resolve this.
Error using nlinfit (line 205)
Error evaluating model function 'model'.
Error in fitting (line 16)
coeff=nlinfit([T,F],dalpha_dt,@model,coeff0);
Caused by:
Attempted to access a(:,2); index out of bounds because numel(a)=1.
Thanks

답변 (2개)

Star Strider
Star Strider 2015년 10월 9일
You defined ‘a’ as a scalar (appropriately) so it is by definition a (1x1) ‘array’ (taking liberties with the concept here). It doesn’t have a second dimension.
How do you want to define ‘T’ and ‘F’?
  댓글 수: 11
R7 DR
R7 DR 2015년 10월 9일
Thank for the information.
I will try to find the solution using genetic algorithms. If I need any help I will come back to you.
Thanks for your time. Have a nice weekend.
Star Strider
Star Strider 2015년 10월 9일
My pleasure.
You, too!

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


R7 DR
R7 DR 2015년 10월 9일
Hi
The idea is that, I have data generated from the experiment. I can also calculate same kind of data from mathematical equation which is depended on two coefficients. Now I need to find these coefficients by fitting the mathematical data with experimental data.
The equations is...dalpha_dt= A*exp(-208000/(8.3417*(T+273)*(F^n)
T=loaded from the excel.
F=loaded from excel.
A & n are the coefficients I want to find.
I made the same calculation using excel with an initial guess of 'A & n' and the curves look like the following image.
Thanks
  댓글 수: 1
R7 DR
R7 DR 2015년 10월 9일
I dont know whether nonlinear function can be used or not for these kind of problems.
Thanks

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

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by