title: fitting parametric equations to data
body: <p>I am to implement this methodology using my data. 
  <a href="https://stats.stackexchange.com/questions/171154/fitting-known-equation-to-data">Fitting known equation to data</a>.
  How ever I have 6 different equations for different intervals of x. </p>
  
  <p>Below is the function I am using to fit the equations</p>
  
  <pre><code>Func &lt;- function(t,t1,t2,t3,t4,t5,t6,a1,a2,a3,a4,a5,a6,b1,b2,c1,c2,c3,c4,c5,c6){
    if(t&lt;t1){
      t*0
    }
    else if(t&gt;=t1&amp;t&lt;t2){
      a1*t+c1
    }
    else if(t&gt;=t2&amp;t&lt;t3){
      a3*t+c2
    }
    else if(t&gt;=t3&amp;t&lt;t4){
      a3*t+c3
    }
    else if(t&gt;=t4&amp;t&lt;t5){
      a4*t**2 + b1*t+c4
    }
    else if(t&gt;=t5&amp;t&lt;t6){
      a5*t**2 + b2*t+c5
    }
    else if(t&gt;=t6){
      a6*t+c6
    }
  }
  
  
  plot(t,w)
  curve(Func(t,1.4,14.4,41.8,60.3,194.3,527,0.0022,0.0029,0.0016,0.00001,0.00001,0.0168,0.0001,-0.0006,0.0063,-0.0433,-0.0022,0.00408,0.2337,-5.3732),add=TRUE)
  </code></pre>
  
  <p>While executing curve function I am getting an error: </p>
  
  <pre><code>Error in curve(Func(t, 1.4, 14.4, 41.8, 60.3, 194.3, 527, 0.0022, 0.0029,  : 
    'expr' must be a function, or a call or an expression containing 'x'
  </code></pre>