1

I have a matlab output function and Output curve characteristics, i would like to obtain the estimated parameter values from the Output curve characteristics , how can i use curve fitting tool box to obtain the 95 percent confidence values

Following is the output function

function c_t = output_function_conv(t, a1, a2, a3,b1,b2,b3,td, tmax,k1,k2,k3)

K_1   = (k1*k2)/(k2+k3);
K_2   = (k1*k3)/(k2+k3);

c_t = zeros(size(t));

ind = (t > td) & (t < tmax);

c_t(ind)= conv(
    ((t(ind) - td) ./ (tmax - td) * (a1 + a2 + a3)),
    (K_1*exp(-(k2+k3)*t(ind)+K_2)),'same');

ind = (t >= tmax);

c_t(ind)= conv(
    (a1 * exp(-b1 * (t(ind) - tmax))+ a2 * exp(-b2 * (t(ind) - tmax))) + a3 * exp(-b3 * (t(ind) - tmax)),
    (K_1*exp(-(k2+k3)*t(ind)+K_2)),'same');

plot(t,c_t);
end

Following are the input values that i have manually allocated

output_function_conv(0:0.01:50,2501,18500,65000,0.9,0.2,0.5,0.7,0.3,0.036,0.02,0.12)

I would like to estimate the 95 percent confidence values of output function characteristic plot.

Kindly let me know how estimation should be performed

Following are the data points for curve fitting

Output [ 0            0            21292.6393733205         20834.1763999840         20385.7118816737   19947.0305575470    19517.9214023497    19098.1775712551    18687.5963435309    18285.9790651943    17893.1310908080    17508.8617245528    17132.9841607124    16765.3154236868    16405.6763076516    16053.8913159642    15709.7886004177    15373.1999004294    15043.9604822502    14721.9090782703    14406.8878264928    14098.7422102414    13797.3209981621    13502.4761845740    13214.0629302211    12931.9395034707    12655.9672220004    12386.0103950142    12121.9362660198    11863.6149562013    11610.9194084135    11363.7253318255    11121.9111472338    10885.3579330675    10653.9493721007    10427.5716988901    10206.1136479486    9989.46640266844    9777.52354500148    9570.18100590553    9367.33701656270    9168.89206037408    8974.74882573439    8784.81215958863    8598.98902177138    8417.18844012873    8239.32146642148    8065.30113300742    7895.04241029970    7728.46216499746    7565.47911908413    7406.01380958819    7249.98854910055    7097.32738704227    6947.95607167558    6801.80201285096    6658.79424548257    6518.86339374380    6381.94163597454    6247.96267029150    6116.86168089246    5988.57530504527    5863.04160075221    5740.20001507995    5619.99135314564    5502.35774774896    5387.24262964033    5274.59069841522    5164.34789402439    5056.46136888997    4950.87946061717    4847.55166529148    4746.42861135114    4647.46203402467    4550.60475032357    4455.81063457978    4363.03459451807    4272.23254785336    4183.36139940305    4096.37901870450    4011.24421812800    3927.91673147547    3846.35719305551    3766.52711722518    3688.38887838929    3611.90569144786    3537.04159268280    3463.76142107467    3392.03080004070    3321.81611958540    3253.08451885496    3185.80386908720    3119.94275694843    3055.47046824929    2992.35697203117    2930.57290501549    2870.08955640789    2810.87885304966    2752.91334490887    2696.16619090368    2640.61114505071    2586.22254293112    2532.97528846746    2480.84484100443    2429.80720268671    2379.83890612722    2330.91700235940    2283.01904906694    2236.12309908497    2190.20768916629    2145.25182900688    2101.23499052463    2058.13709738563    2015.93851477229    1974.62003938789    1934.16288969200    1894.54869636156    1855.75949297240    1817.77770689617    1780.58615040766    1744.16801199767    1708.50684788667    1673.58657373467    1639.39145654262    1605.90610674094    1573.11547046102    1541.00482198505    1509.55975637042    1478.76618224438    1448.61031476500    1419.07866874474    1390.15805193257    1361.83555845114    1334.09856238523    1306.93471151803    1280.33192121178    1254.27836842933    1228.76248589333    1203.77295637992    1179.29870714364    1155.32890447051    1131.85294835633    1108.86046730722    1086.34131325951    1064.28555661621    1042.68348139733    1021.52558050131    1000.80255107504    980.505289989895    960.624889421189    941.152632528815    910.093552396909    880.074844716944    851.060744250693    823.016766773700    795.909660251508    769.707358052245    744.378934099714    719.894559876329    696.225463190064    673.343888624288    651.223059593511    629.837141932191    609.161208947531    589.171207870732    569.843927644531    551.156967988015    533.088709682665    515.618286026374    498.725555404831    482.391074932134    466.596075114855    451.322435495995    436.552661237327    422.269860600652    408.457723290306    395.100499621077    382.182980477300    369.690478030556    357.608807184818    345.924267719382    334.623627101217    323.694103939659    313.123352057611    302.899445154510    293.010862037469    283.446472397999    274.195523112734    265.247625047485    256.592740344874    248.221170176634    240.123542942462    232.290802898093    224.714199195994    217.385275322762    210.295858918002    203.438051960061    196.804221304642    190.386989562840    184.179226305776    178.174039583434    172.364767745896    166.744971555592    161.308426579671    156.049115852013    150.961222794856    146.039124390369    141.277384592926    136.670747973167    132.214133585317    127.902629049538    123.731484841434    119.696108781123    115.792060714591    112.015047380319    108.360917454464    104.825656768093    101.405383690273    98.0963446710064    94.8949099382621    91.7975693435645    88.8009283507997    85.9017041631206    83.0967219830068    80.3829114007349    77.7573029066858    75.2170245230854    72.7592985509469    70.3814384281314    68.0808456946014    65.8550070610841    63.7014915775029    61.6179478976678    59.6021016368462    57.6517528189581    55.7647734102607    53.9391049364990    52.1727561806128    50.4638009581927    48.8103759679823    47.2106787148207    45.6629655025121    44.1655494942032    42.7167988379332    41.3151348551059    39.9590302897151    38.6470076162314    37.3776374041319    36.1495367371296    34.9613676852239    33.8118358277656    32.6996888257886    31.6237150419265    30.5827422062891    29.5756361267334    28.6012994420155    27.6586704163679    26.7467217740917    25.8644595728099    25.0109221140670    24.1851788900145    23.3863295649593    22.6135029905981    21.8658562538011    21.1425737558466    20.4428663220491    19.7659703407560    19.1111469307271    18.4776811359438    17.8648811469268    17.2720775476747    16.6986225873647    16.1438894759878    15.6072717031179    15.0881823790414    14.5860535975035    14.1003358193474    13.6304972763527    13.1760233945998    12.7364162367108    12.3111939623395    11.8998903063055    11.5020540737853    11.1172486519962    10.7450515378264    10.3850538808823    10.0368600414446    9.70008716283935    9.37436475774730    9.05933430799276    8.75464887736619    8.45997273705098    8.17498100323961    7.89935928653744    7.63280335276621    7.37501879479276    7.12572071502023    6.88463341819175    6.65149011416815    6.42603263035222];

Input function Values :

input = [
10      -1          1
20      17956   1
30      61096   1
40      31098   1
50      18446   1
60      12969   1
95      7932    1
120     6213    1
188     4414    1
240     3310    1
300     3329    1
610     2623    1
1200    1953    1
1800    1617    1
2490    1559    1
3000    1561    1
3635    1574    1
4205    1438    1
4788    1448    1
];
calibrationfactor_wellcounter =1.841201569;

The input function for above values is calibrated as follows

function c = Input_function(t, a1, a2, a3, b1, b2, b3, td, tmax)

...some code to model the input function from the Above vector Input

 Plot(t,c);
9
  • @vish,I am a beginner and i dont know how to use cftool for curve fitting, pardon me, if possible, could you please help me in this regard and let me know how i can best use the function in cftool and get best confidence intervals
    – DevanDev
    Feb 24, 2014 at 18:09
  • Curve-fitting supposes to fit curve to some set of datapoints. Where is the data?
    – divanov
    Feb 24, 2014 at 18:32
  • Is your other question a duplicate? Please consider deleting one of them.
    – Ali
    Feb 24, 2014 at 19:09
  • @Ali,No actually i have to compute parameter estimation using Simbiology toolbox in matlab and subsequently i have to do curve fitting, although questions resemble same , but the criterion for implementing is different
    – DevanDev
    Feb 24, 2014 at 19:33
  • @divanov,I have added the data , please kindly review it, Data comprises of 500 points
    – DevanDev
    Feb 24, 2014 at 19:36

1 Answer 1

1

I assume you want to do a line fit (single input -> single output) of a function, f(t; a,b,c,d,e,f)=y. Here, t is your input and y is your output. Now, you have a set of data points, which is something like this

data = [t1 ,y1;
        t2, y2;
        t3, y3;
        ......];

If you do scatter(data(:,1),data(:,2)), you should be able to see your data points distribution. By data fitting, you are going to estimate the parameters a,b,c,d,e,f that minimize the distance between your curve and your data points. I think MATLAB usually use least square for this. Now you define auxiliary function to supply to MATLAB's data fit routine

F = @(x,xdata) f(xdata, x(1),x(2),x(3),x(4),x(5),x(6) );

Note that we just redefined a=x(1),b=x(2), and so on. Then define your initial guess x0 and do the nonlinear least square fit

x0 = [1 1 1 1 1 1];
[x,resnorm,~,exitflag,output] = lsqcurvefit(F,x0,data(:,1),data(:,2))

You probably need to tweak initial guess, convergence criteria, etc, but if you succeed, then you get your a,b,c,d,e,f values in the vector x. So, you can plot

scatter(data(:,1),data(:,2))
hold on
plot(data(:,1),F(x,data(:,1));
hold off

and you should be able to see your data points and your curve.

All you need to do is modify your output_function_conv so that for each t value, you get one c_t value because it seems that right now your function returns a vector. Also, your initial guess and convergence criteria can be quite important to make the least square converge.

ref: http://www.mathworks.com/help/optim/examples/nonlinear-data-fitting.html

6
  • :My main goal is to estimate the values of K1,K2,K3 from the output curve the estimated values must closely match to my experimental data K1=0.036,K2=0.02,K3=0.12 .... I wish to get a output for every single value of input t, and from that output function i would like to estimate the values of K1,K2,K3...usually , i manually input the values of K1,K2,K3 to compute output functions, now i would like to find out some approximate estimates..I am not sure how i could accomplish it.I am very new to matlab programming
    – DevanDev
    Feb 25, 2014 at 0:36
  • You can still do line fit using fmininc. From your comment, I assume that you set a1, a2, a3,b1,b2,b3,td, tmax as constants. However, you still have not provided the data set of t values and c_t values.
    – ysakamoto
    Feb 25, 2014 at 1:07
  • I apologize for delayed response, The values for t are (0:0.01:50) its a 50 minutes duration with 0.01 sampling step rate and the values for Concentration c_t are shown in Output Vector given in the question... the concentration basically varies between C=(0:80000) basically expressed in MBq--Its a tracer concentration with F18 radioactive isotope
    – DevanDev
    Feb 25, 2014 at 10:43
  • Size of 0:0.01:50 vector is 5001 while your output has 300 size. I don't think this is a MATLAB problem. You critically lack the understanding of curve fit.
    – ysakamoto
    Feb 25, 2014 at 17:33
  • Yes, As i mentioned before i am a beginner ,so i acknowledge that i have some problems, but i need some clarification in regard with curvefitting
    – DevanDev
    Feb 26, 2014 at 10:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.