How to fit a function with mutiple variables
2 views (last 30 days)
Show older comments
Hello everyone,
I have a problem related to the fitting of a function which contains multiple variables. I usually use the command lsqcurvefit to fit a function with only one varibales such as times (y = f(t)) but this time the function that I have to fit turns to this :
y = f(alpha*x,t)
x is a vector calculed from 2 look-up tables a and b. And we have a,b vary with times
t = [0 : 30 : 9000]
My goal is to find alpha for each value of a and b because later I want to create a look-up table of alpha that match with a and b. If I'm correct, it means at each step of times, I have to find an alpha that allows having a best fit of f with the curve between y(i) and y(i-1).
I tried to do this with a for loop but it doesn't work so I want to know your advises for my problem. May be I'm wrong from the beginning.
a = ([0 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100])/100;
b = [-20 -15 -10 -5 0 5 10 15 20 25 30 35 40 45 50 55 60] ;
x = interp2(a,b,x_out,a_measure,b_measure) ;
A = (1/Rth_int)+(1/Rth_ext) ;
fitfun =@(alpha,times) (Temp_init-(A*Temp_ext+alpha*x.*(Imp.^2))/A).*exp(-(A*times)/(masse*Cp)+((Temp_ext*A+alpha*x.*(Imp.^2))/A);
May be I don't explain well the problem so if you guys have any questions please let me know. Thanks a lot.
0 Comments
Answers (1)
See Also
Categories
Find more on Interpolation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!