Hi.
I'm a simple question with matematic equation.
I have this equation:
tempC= 5.4446*ln(tempC) - 15.733;
but when i compile the Arduino don't accept ln(x)
thelog (x)
is different in Arduino right?
there is a library that can i use?
thanks
Hi.
I'm a simple question with matematic equation.
I have this equation:
tempC= 5.4446*ln(tempC) - 15.733;
but when i compile the Arduino don't accept ln(x)
thelog (x)
is different in Arduino right?
there is a library that can i use?
thanks
(updated)
log(x) == ln(x) log(x) is the logarithmus naturalis
for other bases you can use something like this
float logZ(float x, float z) { log(x) / log(z) }
or use a fixed value for Z
float log100(float x) { log(x) * 0,21714724095; }
note that log10(x) is part of the math lib - avr-libc: <math.h>: Mathematics -
so you can use that directly.
my Equation:
tempC= 5.4446*ln(tempC) - 15.733;
you mean doing this:
tempC= 5.4446* float ln(float tempc) - 15.733 { log(tempC) / log(e) }
??
I've updated my post see above.
The equation: TempC= 5.4446*ln(tempC) - 15.733;
translates to
TempC = 5.4446 * log(tempC) - 15.733;
I think one of the tempC's is a rawMeasurement or so, and as it is a parameter for log() it should be tested if not negative.
float raw = measurement();
if (raw > 0) TempC = 5.4446 * log(raw) - 15.733;
else ERROR HANDLING CODE
and if i have this:
y = 17.989e^(0.1837x)
i use log?
PedroS23:
and if i have this:y = 17.989e^(0.1837x)
i use log?
This is the correct equation:
tempC= 17.989exp(0.1837tempC);
yes,
please use variable names that reflect their meaning.
tempC= 17.989exp(0.1837tempC);
The green tempC is probably indeed a temperature, while the red tempC is probably a calculated resistance or current?
for a small piece of code this is no problem, for larger programs it makes/brakes the maintainability
yes, i'm convert Volts to temperature..
thanks
robtillaart:
float log100(float x) { log(x) * 0,21714724095; }
Remember, you have to be American and use a decimal point, not a decimal comma.
float log100(float x) { log(x) * 0.21714724095; }
Or, you could use something like this:
float logb (float x, float b) { // gives logarithm of number x to base b
return (log(x) / log(b));
}
And, for exponentiation, you already have the pow function, so that pow(7.0, 2.0) gives 49.0, and pow(5.0, 3.0) gives 125.0.
odometer:
robtillaart:
float log100(float x) { log(x) * 0,21714724095; }
Remember, you have to be American and use a decimal point, not a decimal comma.
float log100(float x) { log(x) * 0.21714724095; }
Sorry,
As windows follows my dutch keyboard layout I often get these typos
Its a full-stop, not a decimal point really - Unicode has true decimal point these days,
but back when there was only ASCII and EBCDIC they shared the same symbol for
decimal point and full stop.
The old teletypes actually printed it intermediate in height between a decimal point
and a full stop!
Unicode 00B7 is "middle dot" which you would use in mathematical contexts.
MarkT:
Unicode 00B7 is "middle dot" which you would use in mathematical contexts.
I was taught that the middle dot means multiplication. So you could have something like: 2.5·2=5