How to draw a series of TF1 curves?

From: <osirixu-root_at_yahoo.com.cn>
Date: Wed, 30 Jan 2008 11:41:19 +0800 (CST)


Hi all,

    I expect to plot a series of curves (or vectors of a field) on one single canvas, e.g. such functions: f(x)=x^2+Ci, where Ci is a constant varies from 1 to 100. I tried to use codes below but failed.

//++++++++++++++++++++++start+++++++++++++++++++++++++++++++
double testfunc(double* x, double* par) {   double c = par[0];
  return x[0]**x[0]+c;
}

void fieldraw() {
  for (double Ci=1;Ci<=100;Ci++)
  {
  TF1* vectorfunc = new TF1("vectorfunc",&testfunc,-5,5,1);   vectorfunc->SetParameters(Ci);
  vectorfunc->Draw("L");
}

  return;
}

//++++++++++++++++++++++end++++++++++++++++++++++++++++++
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// OR
//++++++++++++++++++++++start+++++++++++++++++++++++++++++++
double testfunc(double* x, double* par) {   double c = par[0];
  return x[0]**x[0]+c;
}

void fieldraw() {
  TF1* vectorfunc = new TF1("vectorfunc",&testfunc,-5,5,1);   for (double Ci=1;Ci<=100;Ci++)
  {
  vectorfunc->SetParameters(Ci);
  vectorfunc->Draw("L");
}

  return;
}

//++++++++++++++++++++++end++++++++++++++++++++++++++++++

Thr error message both are: "Error: Can't call TF1::SetParameters(Ci) in current scope"

     I am puzzled what is going wrong?

    Any tips will be greatly appreciated. Thanks and have a nice day!

    Sincerely,
    Shrinking



ÑÅ»¢ÓÊÏä´«µÝÐÂÄê×£¸££¬¸öÐԺؿ¨ËÍÇ×Åó£¡
http://cn.mail.yahoo.com/gc/index.html?entry=5&souce=mail_mailletter_tagline Received on Wed Jan 30 2008 - 04:41:43 CET

This archive was generated by hypermail 2.2.0 : Wed Jan 30 2008 - 11:50:01 CET