Residual analysis

I am trying to Fit my data linearly and also get the residual plot below it.
Here is my code. I am failing to understand what I am doing incorrectly.
Calib.C (1.8 KB)

Can you please show me the right way to do it? I am also attaching the data file.
data1.txt (274 Bytes)

Your code has C++ mistakes:


Energy and Channel are not arrays. Try to fix that.

1 Like

Hi. I am relatively new to C++.
I tried to do something but there is still error due to float not being a structure. Can you please help me fix this?
Calib.C (2.0 KB)
or union.

Energy and Chanel are simple float numbers:

    float Channel, Energy;

You cannot use at() or size() or any function on them. Your logic in wrong.

Thanks for the suggestions. I learned that we can store data into many ways and then proceed.
For for now I tried this and it’s giving me the right answer.
I also tried it with arrays.

file >> Channel >> Energy;
gr2->SetPoint(gr2->GetN(), Energy, cal);
if(file.eof()) break;