添付ファイル 'ex_graph.C'

ダウンロード

   1 /*
   2   ex_graph.C
   3   ==========
   4   TGraph is used to plot a set of two-dimensional points.
   5   As inputs, TGraph requires the number of points, two arrays of float; 
   6   an array of X-coordinates and an array of Y-coordinates.
   7   There are variants of TGraph such as TGraphErrors (for symmetric errors)
   8   and TGraphAsymmErrors (for asymmetric errors). For these, additional
   9   arrays are needed to provide the size of the errors.
  10 
  11   When plotting TGraph on a new TPad, one usually should provide some drawing
  12   options.
  13   Options:
  14     'a': Draw axis
  15     'p': Draw points
  16     'l': Draw lines between adjacent points
  17   They can be given together like g->Draw("alp");
  18   Or just give the option "same" when superimposing on an existing TPad.
  19 */
  20 
  21 TF1* func1 = new TF1("fsin", "[0]*sin([1]*x)", -100, 100);
  22 
  23 void ex_graph() {
  24   const Int_t N=100;
  25   Float_t x[100];
  26   Float_t y[100];
  27   Float_t ex[100];
  28   Float_t ey[100];
  29   int i;
  30 
  31   TRandom3 random;
  32   random.SetSeed(25701);
  33 
  34   TGraph* g1(0);
  35   float dx=0.1;
  36 
  37   for (i=0; i<N; ++i) {
  38     x[i] = i*dx;
  39     y[i] = sin(x[i]+random.Gaus(0.0, 0.05));
  40     ex[i] = 0.1*dx;
  41     ey[i] = 0.05;
  42   }
  43   g1 = new TGraphErrors(N, x, y, ex, ey);
  44   g1->SetMarkerStyle(20);
  45 
  46   TCanvas* c = new TCanvas("c", "", 600, 0, 500, 500);
  47   g1->Draw("alp");
  48   func1->SetParameter(0, 1.0);
  49   func1->SetParameter(1, 1.2);
  50   g1->Fit(func1, "", "", 0, 10.0);
  51 }

添付ファイル

添付ファイルを参照するには、(下のファイル一覧にあるように)attachment:filenameと記述します。 [get]リンクのURLは変更される可能性が高いので、利用しないでください。
 All files | Selected Files: delete move to page copy to page

ファイルを添付する権限がありません。