// Define known points
float x1_value = 80.95238095; // x value of first known point
float y1_value = 445; // y value of first known point
float x2_value = 89.68253968; // x value of second known point
float y2_value = 536.87; // y value of second known point
// Known x value for prediction
float x3_value = 6;
// Function to perform linear interpolation and calculate y3
float interpolate(float x1, float y1, float x2, float y2, float x3) {
// Calculate slope (m)
float slope = (y2 - y1) / (x2 - x1);
// Calculate y value for the given x3
float y3 = y1 + slope * (x3 - x1);
return y3;
}
void setup() {
Serial.begin(9600);
// Perform interpolation
float interpolated_y = interpolate(x1_value, y1_value, x2_value, y2_value, x3_value);
// Print result
Serial.print("Interpolated Y value for x3 = ");
Serial.println(interpolated_y);
}
void loop() {
// Nothing to do in the loop for this example
}