Search code examples
juliacurve

Julia rotation and torque curve


I know of the idea how I would like to do it, but have no clue how to do it in Julia. So I have graph of motor torque/rotation curve. I can collect data to arrays, like

torque[0,10,12,15,10,0]
rotation[0,1000,2000,3000,4000,5000,6000]

Maybe this can be done better, but the idea is when rotation is 1000 the output is 10 and when rotation is 2000 the output is 12. Or other way. Like if I want 12Nm the output is 2000. That's easy to make. But what about when if I want 9Nm or 13Nm? I can make function to calculate the line between two values, but I was thinking this is common problem so maybe there is build in function for such cases. So is there?


Solution

  • If what you mean is curve fitting you can use the CurveFit package, with methods like:

    a,b = linear_fit(rotation,torque)
    

    method, which returns a and b so that

    torque = a + b * rotation
    

    If its not linear you can use poly_fit, power_fit or whatever function describes your data, but as I recall torque is related to rotation squared, so either poly_fit or power_fit should be what you need