Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TugboatEng on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to program PLC for least Squares

Status
Not open for further replies.

dougplc

Electrical
Joined
May 2, 2006
Messages
2
Location
US
Can someone help me determine how to program a least squares routine for determining the slope and intercept for a number of xy coordinates? I am using an AB Micrologix 1100. Thanks.
 
This is sort of a dirty solution but you place your x data in the array starting at f9:0 and the corrosponding y data in F10:0. Then you place the number of data points in N7:1. Call the routine and it returns A in f11:12 and B in F11:16. Use the equation y = A + Bx for your curve fitting.

I have uploaded a file but have not tested it but you should see how it works if I made a mistake.

Lanny
 
 http://files.engineering.com/getfile.aspx?folder=214834be-5006-47e8-a44a-7fa74ba4490b&file=LEASTSQU.RSS
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top