Menu

fitting function to data over two (or more) intervals at the same time

Help
peterp
2015-08-22
2015-08-22
  • peterp

    peterp - 2015-08-22

    Hello,
    I need to fit a function to my data over two disjointed ranges on the x axis at the same time.
    Is there a way of the type 'fit f(x) [x=xmin:xmax] [x=xmin1:xmax2] to do this?
    Unfortunately, Gnuplot will interpret the second range as a y-range even if I specify that the variable is x.
    Any suggestions?
    Thank you in advance.

     
  • Christoph Bersch

    You can invalidate the data points which are outside of the two ranges with

    fit f(x) 'datafile' using (($1>=xmin && $1 <= xmax) || ($1 >= xmin1 && $1 <= xmax1) ? $1 : 1/0):2 via ...
    
     
  • peterp

    peterp - 2015-08-22

    Ok, thank you. And what if I want to associate a certain data set to the first interval and another data set to the second? How do I make the fit (or even the plot)?
    I tried

    plot 'datafile' (($1>=xmin && $1 <= xmax) || ($1 >= xmin1 && $1 <= xmax1) ? (i i0) : (i i1))

    (the fit command should be similar), but without success.
    Finally, what if I want to do the same with 3 data sets (say i=0 in [xmin:xmax], i=6 in [xmin1:xmax1] and i=8 in [xmin2:xmax2]?

     

    Last edit: peterp 2015-08-22

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.