I’m trying to plot d(In(I))/dV on the x-axis and V on the y-axis. I’m currently stuck at calculating d(In(I))/dV.
I paste a copy of my code in this post, and I will be glad if anyone can help me out.
void ivcurve2()
{
gROOT->SetBatch(kTRUE);
gStyle->SetOptStat(0);
gStyle->SetOptTitle(0);
gStyle->SetTitleSize(0.05,"XY");
gStyle->SetTitleOffset(.9, "XY");
gStyle->SetStatY(0.9);
gStyle->SetStatX(0.9);
TCanvas *c1 = new TCanvas("c1", "c1",18,41,700,500);
c1->Range(24,50,40,70);
hDummy = new TH2D("hDummy","hDummy",1000,0,80,1000,0,3);
hDummy->Draw("axis");
hDummy->GetXaxis()->SetTitle("Voltage [V]");
hDummy->GetYaxis()->SetTitle("Current [A]");
hDummy->GetXaxis()->CenterTitle();
hDummy->GetYaxis()->CenterTitle();
const Int_t n = 4;
//Setting data for voltage and current
Float_t voltage[n] = {5.0456,6.625,10.9227,15.0141, 21.7676,23.3653};
Float_t current[n] = {0.1315,0.23,0.5317,0.8374, 1.0021, 1.2021};
Float_t currentI[n] = {};
float currentNaturalLog = 0.0;
for (int i = 0; i < n; i++)
currentNaturalLog = log(current[i]);
//Finding the derivative for current.
double x1 = currentNaturalLog[0]
double x2 = currentNaturalLog[1]-currentNaturalLog[0]
double x3 = currentNaturalLog[2]-currentNaturalLog[1]
double x4 = currentNaturalLog[3]-currentNaturalLog[2]
double x5 = currentNaturalLog[4]-currentNaturalLog[3]
double x6 = currentNaturalLog[5]-currentNaturalLog[4]
//Finding the derivative of voltage
double v1 = voltage[0]
v2 = voltage[1]-voltage[0]
v3 = voltage[2]-voltage[1]
v4 = voltage[3]-voltage[2]
v5 = voltage[4]-voltage[3]
v6 = voltage[5]-voltage[4]
float dNaturallogI[n] = {x1,x2,x3,x4,x5,x6}
float dV[n] = {v1,v2,v3,v4,v5,v6}
TGraph *iv_curve = new TGraph(n,voltage,current);
iv_curve->SetMarkerStyle(20);
iv_curve->SetMarkerColor(kRed);
iv_curve->Draw("p same");
TF1 *iv_curvefit = new TF1("iv_curvefit","[0]+x*[1]",0,1);
iv_curvefit->SetLineColor(kRed);
iv_curve->Fit("iv_curvefit");
///TImage *img = TImage::Create();
///img->FromPad(c1, 10, 10, 300, 200);
///img->FromPad(c1);
///img->WriteImage("ivcurve.png");
}
ivcurve2.C (2.0 KB)