How to fit a function with mutiple variables

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

回答(1 个)

Jos (10584)
Jos (10584) 2016-6-21
So you're fitting a surface in 3D space, z = f(x,y)
  1 个评论
Tuan-Tu
Tuan-Tu 2016-6-21
编辑:Tuan-Tu 2016-6-21
Thank for your answer but I'm not sure because my output parameter y is just a vector size 308*1. I tried to plot a surface in fonction of x and time but it doesn't work. You know how could I do this ? Thank you

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Get Started with Curve Fitting Toolbox 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by