Filter löschen
Filter löschen

How to fit a function with mutiple variables

3 Ansichten (letzte 30 Tage)
Tuan-Tu
Tuan-Tu am 21 Jun. 2016
Bearbeitet: Tuan-Tu am 21 Jun. 2016
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.

Antworten (1)

Jos (10584)
Jos (10584) am 21 Jun. 2016
So you're fitting a surface in 3D space, z = f(x,y)
  1 Kommentar
Tuan-Tu
Tuan-Tu am 21 Jun. 2016
Bearbeitet: Tuan-Tu am 21 Jun. 2016
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

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Get Started with Curve Fitting Toolbox finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by