Question: Please help. The Program is C++, thanks! The force (Y) generated by a spring is a function of the springs displacement(X). The plot below shows
Please help. The Program is C++, thanks!
The force (Y) generated by a spring is a function of the springs displacement(X). The plot below shows the relationship between displacement and force. The greater the displacement, the greater the force generated. By inspection, the relationship appears to be linear.
Create a linear regression program that outputs the slope and y-intercept of the best fit line for a set of ordered pairs. Corresponding elements in the displacement and force arrays form ordered pairs. The program must have five user defined functions as outlined below.
Populate two arrays(X[],Y[]) using data in lin_reg.txt, you must use file input.
Multiply two arrays
Square an array
Calculate the slope of the best fit line
Calculate the y-intercept of the best fit line
The force (Y) and displacement (X) data is in the file lin_reg.txt. You can not modify lin_reg.txt, you must use it as is.
The lin_reg.txt file contains these values in this format:
X(m) -.0015 -.0039 -.0058 -.0079 -.0101 -.0119 -.0143 -.0157 -.0179 -.0198 Y(N) 17 42 54 84 105 121 159 170 199 216
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
