curve fit using a custom equation from command line without using cftool









up vote
1
down vote

favorite












I have some data that is curve fitting nicely using custom equation from cftool. The equation is: y = aexp(-bx)+c. Is there any way to make this same equation available from the command line? For instance using fit command and exp1 gives following results:



f = fit(time,T102,'exp1')

f =

General model Exp1:
f(x) = a*exp(b*x)
Coefficients (with 95% confidence bounds):
a = 0.0726 (0.0717, 0.0735)
b = -1.263e-05 (-4.171e-05, 1.645e-05)


However the form of this equation does not fit my data well. I need to have the equation as f(x) = aexp(bx) + c. I am aware that I can get it from cftool but I have many different sets of data to curve fit (~30) and I just want a, b, and c returned from by MATLAB in the custom equation f(x) = aexp(bx) + c.










share|improve this question

















  • 1




    Is this link helpful? stackoverflow.com/questions/10890438/…
    – James Phillips
    Nov 11 at 20:05














up vote
1
down vote

favorite












I have some data that is curve fitting nicely using custom equation from cftool. The equation is: y = aexp(-bx)+c. Is there any way to make this same equation available from the command line? For instance using fit command and exp1 gives following results:



f = fit(time,T102,'exp1')

f =

General model Exp1:
f(x) = a*exp(b*x)
Coefficients (with 95% confidence bounds):
a = 0.0726 (0.0717, 0.0735)
b = -1.263e-05 (-4.171e-05, 1.645e-05)


However the form of this equation does not fit my data well. I need to have the equation as f(x) = aexp(bx) + c. I am aware that I can get it from cftool but I have many different sets of data to curve fit (~30) and I just want a, b, and c returned from by MATLAB in the custom equation f(x) = aexp(bx) + c.










share|improve this question

















  • 1




    Is this link helpful? stackoverflow.com/questions/10890438/…
    – James Phillips
    Nov 11 at 20:05












up vote
1
down vote

favorite









up vote
1
down vote

favorite











I have some data that is curve fitting nicely using custom equation from cftool. The equation is: y = aexp(-bx)+c. Is there any way to make this same equation available from the command line? For instance using fit command and exp1 gives following results:



f = fit(time,T102,'exp1')

f =

General model Exp1:
f(x) = a*exp(b*x)
Coefficients (with 95% confidence bounds):
a = 0.0726 (0.0717, 0.0735)
b = -1.263e-05 (-4.171e-05, 1.645e-05)


However the form of this equation does not fit my data well. I need to have the equation as f(x) = aexp(bx) + c. I am aware that I can get it from cftool but I have many different sets of data to curve fit (~30) and I just want a, b, and c returned from by MATLAB in the custom equation f(x) = aexp(bx) + c.










share|improve this question













I have some data that is curve fitting nicely using custom equation from cftool. The equation is: y = aexp(-bx)+c. Is there any way to make this same equation available from the command line? For instance using fit command and exp1 gives following results:



f = fit(time,T102,'exp1')

f =

General model Exp1:
f(x) = a*exp(b*x)
Coefficients (with 95% confidence bounds):
a = 0.0726 (0.0717, 0.0735)
b = -1.263e-05 (-4.171e-05, 1.645e-05)


However the form of this equation does not fit my data well. I need to have the equation as f(x) = aexp(bx) + c. I am aware that I can get it from cftool but I have many different sets of data to curve fit (~30) and I just want a, b, and c returned from by MATLAB in the custom equation f(x) = aexp(bx) + c.







matlab curve-fitting






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 11 at 12:54









PatStarks

5610




5610







  • 1




    Is this link helpful? stackoverflow.com/questions/10890438/…
    – James Phillips
    Nov 11 at 20:05












  • 1




    Is this link helpful? stackoverflow.com/questions/10890438/…
    – James Phillips
    Nov 11 at 20:05







1




1




Is this link helpful? stackoverflow.com/questions/10890438/…
– James Phillips
Nov 11 at 20:05




Is this link helpful? stackoverflow.com/questions/10890438/…
– James Phillips
Nov 11 at 20:05












1 Answer
1






active

oldest

votes

















up vote
1
down vote













I ended up finding my answer using information from following link:
https://www.mathworks.com/help/curvefit/fit.html




  1. Create a matlab function that contains custom equation for fit



    function y = CustomCurveFitFunction(x,a,b,c)



    y = aexp(-bx) + c;



    end




  2. Call the function in the following manner from MATLAB



    ft = fittype('CustomCurveFitFunction(x, a, b, c)');



    f = fit(time, y, ft);






share|improve this answer




















    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53248948%2fcurve-fit-using-a-custom-equation-from-command-line-without-using-cftool%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    1
    down vote













    I ended up finding my answer using information from following link:
    https://www.mathworks.com/help/curvefit/fit.html




    1. Create a matlab function that contains custom equation for fit



      function y = CustomCurveFitFunction(x,a,b,c)



      y = aexp(-bx) + c;



      end




    2. Call the function in the following manner from MATLAB



      ft = fittype('CustomCurveFitFunction(x, a, b, c)');



      f = fit(time, y, ft);






    share|improve this answer
























      up vote
      1
      down vote













      I ended up finding my answer using information from following link:
      https://www.mathworks.com/help/curvefit/fit.html




      1. Create a matlab function that contains custom equation for fit



        function y = CustomCurveFitFunction(x,a,b,c)



        y = aexp(-bx) + c;



        end




      2. Call the function in the following manner from MATLAB



        ft = fittype('CustomCurveFitFunction(x, a, b, c)');



        f = fit(time, y, ft);






      share|improve this answer






















        up vote
        1
        down vote










        up vote
        1
        down vote









        I ended up finding my answer using information from following link:
        https://www.mathworks.com/help/curvefit/fit.html




        1. Create a matlab function that contains custom equation for fit



          function y = CustomCurveFitFunction(x,a,b,c)



          y = aexp(-bx) + c;



          end




        2. Call the function in the following manner from MATLAB



          ft = fittype('CustomCurveFitFunction(x, a, b, c)');



          f = fit(time, y, ft);






        share|improve this answer












        I ended up finding my answer using information from following link:
        https://www.mathworks.com/help/curvefit/fit.html




        1. Create a matlab function that contains custom equation for fit



          function y = CustomCurveFitFunction(x,a,b,c)



          y = aexp(-bx) + c;



          end




        2. Call the function in the following manner from MATLAB



          ft = fittype('CustomCurveFitFunction(x, a, b, c)');



          f = fit(time, y, ft);







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 12 at 5:06









        PatStarks

        5610




        5610



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53248948%2fcurve-fit-using-a-custom-equation-from-command-line-without-using-cftool%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Top Tejano songwriter Luis Silva dead of heart attack at 64

            政党

            天津地下鉄3号線