Mechatronics Homework help - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Homework (https://python-forum.io/forum-9.html) +--- Thread: Mechatronics Homework help (/thread-14085.html) |
Mechatronics Homework help - Cwcox - Nov-14-2018 Hello, I was wondering if I could get some instruction on where to begin with this homework question I'm having difficulty understanding. I'll post a picture of the question but there are a few things I'm having trouble even getting started with so if I could get a walkthrough on where to at least get started with the code and a few helpful pointers I'll be very appreciative. To begin, the HW08data.txt file. How can I get the file loaded into the program so I can assign the data to variables? Once I have the variables, which I believe is actually 16 points of (x,y) values. I know I need to run a while loop to calculate m for all 16 points and then use m to calculate r, this r value should be between 0 and 1. Once that value is calculated, I need to remove a point from the loop and recalculate r to see if it moves closer to 1, if it does I continue the loop up until it stops increasing closer to 1. So thats where I'm at and if I could at least get a framework on where to begin i think I can get an understanding of what to do. Thank you! Here are the 2 pictures of the question https://drive.google.com/file/d/1HsOZVlgIGlkLNDwx7hH1buhvBZGw2QSU/view?usp=sharing https://drive.google.com/file/d/1l6EfDYY7Qnmtsvd1GM7tCo79xovk-_w4/view?usp=sharing Here is the link for the HW08data.txt file. https://drive.google.com/file/d/1nvSuJpZfeOw_1mV6KjB5OTbVpxVUUI2F/view?usp=sharing RE: Mechatronics Homework help - Larz60+ - Nov-14-2018 Quote:How can I get the file loaded into the program so I can assign the data to variableshttps://www.pythonforbeginners.com/files/reading-and-writing-files-in-python For the linear regression and other math, you can use numpy and matplotlib: numpy: http://www.numpy.org/ matplotlib: https://matplotlib.org/ If you are required to do the math from scratch, here's a couple of sites: linear regression: https://www.geeksforgeeks.org/linear-regression-python-implementation/ https://mubaris.com/posts/linear-regression/ getting the data loaded, just cut and paste into (between brackets, separated by comma's: datapoints = []Don't forget, google can find most anything! |