formula used to calculate the slope of an XYZ graph

Guest

Guest
G
I am sure at least one of this site’s brilliant minds can assist me with this…
My wife requested I find a program, excel macro, or simply the correct formula and I will create the macro, from which she can upload a spreadsheet of data (3 variables per sample) which will determine the polynomial algorithm for the formula used to calculate the slope of the XYZ graph. The formula, once determined, can be programmed into a PLC or DCS to display, and eventually control, one of the 3 variables when presented with the other 2 (one from manual entry and one from continuous sampling of specific gravity via mass flow meter)
 
Is the data linear in the two dependant variables? You really need to give more informaiton about what this data looks like.

If it is always the same linear relationship, then PLC calculation should be ok.

If it is non-linear but always the same then you could probably program a look up table in the PLC.

If it is non-linear AND changing then you may need to find some hooks into a vb program or excel or mathCAD or something with some numerical analysis smarts.

Can you post a sample of the data? Make sure you state which is the variable you want to calculate.

nOrM
 
If you have three cartesian points (A, B and C) you can find two vectors AB and AC and then take the cross product N = AB X AC to find a vector normal to the surface. You can normalize the vector by dividing by the magnitude of N. You may then use the dot product to find the component that lies in the wanted direction (i.e. perpendicular to the axis of rotation of your actuator).
 
thanks

Thanks nOrM and Hugh for the responses.

nOrM, I don't have a clue what the data looks like right now... will have to question wife on that. (I am on a job assignment in Il. and she had just e-mailed the request to me)
As for the which variable to calculate for, I think she wanted to have multiple formulas so that any 2 variables provided would calculate the 3rd which would allow for cross checking of results.

Hugh, I believe you are right on target for what she wants and I will have to run the numbers (as soon as she gets them to me) to be sure.

By the way, sorry I didn't id myself in the original post... way too hectic around here.....
 
Think Least Squares Estimation.

The LINEST function of Excel or Mathcad can be used to estimate the formula for a plane when there are multiple sets of data. The equation for a plane is a*x+b*y+c*z=k. From this David can calculate the third variable given the other two. The trick is to calculate the coefficients a,b and c using Excel's LINEST equation or Mathcad. David, mentioned polynomials. If the points are not on a plane but on a curved surface then one must assume another basic formula, but still the LINEST function can calcuate the coefficients. Maybe the function looks like:
a*x^2+b*x*y+c*x+d*y^2+e*y*z+f*y+g*z^2+h*z*x+i*z+j=0

I have know idea what the equation should be. You must know what the final equation will look like. In the case above you would need to find a,b,c,e,f,g,h,i and j. This is not trival, but LINEST or Mathcad should be able to solve this easily. I don't think that solving for the coefficents can be done in a PLC. However, once the coefficients are found one can calculate a variable given the other two in the PLC.
 
Adding to what Peter said, you can use the LINEST function in Excell to calculate the coefficients for non-lnear functions. The function will calculate "linear" relationships for more than one variable. If you have a non-linear function that is well behaved (a smooth curve without a lot of minimums or maximums) you can use the form he indicated. Use each of the independent variables as a column in the X aray. Use the square and cube of the independent variables as another column in the array. The function will calculate the coefficients for each separately, and a constant.

Another technique is to isolate one of the independent variables, and solve a regression (LINEST) for each separtely. Then you will have a family of equations, with separate coefficients for each set of the family.

I use this technique often, for example, to model blower or pump curves.
 
Thanks

Peter and Tom,
Thanks a million! :D
I think that is exactly what she needed. From what little I understand from her, she is wanting to perform some modeling of various conditions to determine the best form of control and then use that information as a basis for her recommendations on automation of the system.

I have forwarded her all of the responses and whenever she gets back to me with the data, I will post it so you guys can see the results.

Again, thanks to all :site:
 

Similar Topics

Does anybody have a Scaler Formula they would share? Thanks
Replies
11
Views
4,377
Hello all, I'm stuck on some code I want to write. The idea is to have a formula that accepts a DINT tag setpoint, compares it to the previous...
Replies
6
Views
2,441
Hi All, It probably has been discussed before....but... My PLC is a AB L71 Processor (RSLogix5000 v20) I have a Horizontal Round Cylinder Tank...
Replies
27
Views
11,250
Based on your components, how do you calculate what size air conditioner you need for your control panel?
Replies
6
Views
2,341
hi guys, is there any formula to calculate input maximum value in SCP block where input minmum value is -25383 on 0Kg what will the maximum...
Replies
1
Views
1,631
Back
Top Bottom