So I am trying to run this code to show this sum of angle of conductance and incremental conductance. Conductance is current over voltage. I have sensors connected to the Arduino to detect current and voltage. However when I run the code, it displays Nan. I think the value of the angle could be zero or undefined hence it is not a number. I have included the main part of the code that is not working as I planned. PLease let me know what I can do.
deltaV = Vin_new - Vin_old;
deltaC = Cin_new - Cin_old;
theta = (atan(Cin_new/Vin_new) + atan(deltaC/deltaV)) * 180/3.14159265;
Vin could be values from 10-25V.
Cin from 0.5-2A.
Theta should be from -90 to 90.
But theta sometimes shows as Nan. I need to fix this.