Computes the least squares fit of the data, Programming Languages

Assignment Help:

Your solution to the problem should be housed within a while loop, which allows the grader to test your solution repeatedly without having to re-execute the script, as shown in class. You should first display the purpose of the program, and then you should prompt the user if he/she wishes to run the code. If the user responses 'y' or 'Y', you should then run the actual problem solution (whatever that entails). After running your solution, you should prompt the user if he/she wishes to run it again, and if so, do so. Otherwise, exit the program with a closing goodbye statement.

In this final project you will implement a user-defined matlab function named lsquares with the following "prototype":

function [m,b,e,s,r] = lsquares(x,y)

which computes the least squares regression line fit to the data whose coordinates are in the arrays x and y. The output arguments m and b are always computed and returned, but the user has the option to get e,s and r, if he/she so desires. If these outputs are not requested, your code in your function should NOT compute them.

You will code up the function lsquares in the .m file "lsquares.m", and also a driver program which performs the following steps (as long as the user wants to do so):

1) Prompt the user for a plain text data file, which has 4 columns of data: the first column is string data, the remaining 3 are numeric.

2) Read the second, third, and fourth columns into the variables x,y,and y_true, respectively.

3) Prompts the user for whether he/she wants to see the correlation coefficient r.

4) Computes the least squares fit of the data. You are to obtain r only if the user so desired. On the same plot, plot the x vs. y data with red stars, x vs. the least squares fit with solid blue line, and x vs. y_true with a solid green line. You should output to the user the resulting slope, intercept, and r value (only if the user requested that piece of information).

EXTRA CREDIT: In addition to using your function, lsquares, to compute the least squares fit, use the built-in matlab function polyfit to find the coefficients m and b. Display matlab's m and b values and compare them to yours.


Related Discussions:- Computes the least squares fit of the data

Shell script to print pyramid, Normal 0 false false false ...

Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4

Develop an application for spacerocks game, Extend the SpaceRocks game and ...

Extend the SpaceRocks game and provide a warp feature which allows the ship to jump to a random location to escape a rock. The warp feature is only activated once the shields have

Windows card space, Windows Card Space Windows Card Space (codenamed Info C...

Windows Card Space Windows Card Space (codenamed Info Card), is Windows now-canceled customer application for the Identification Met system. Card Place is an instance of a class of

Jsp - quiz, JSP QUIZ ASSIGNMENT SHOULD BE FUNCTIONAL ON ECLIPSE QUIZ HAS ...

JSP QUIZ ASSIGNMENT SHOULD BE FUNCTIONAL ON ECLIPSE QUIZ HAS TOTAL 20 QUESTIONS REGARDING VARIOUS CAPITALS OF COUNTRIES. WELCOME PAGE OFFERS USER TO ENTER HIS NAME. THEN USER C

Need help for crowdsporting website development, CrowdSporting Website Deve...

CrowdSporting Website Development I want an advanced web developer to spend 1-2 days coding our newly designed website. It will be a single page scrolling site, fully designed a

Calculating percentage differences-circuit diagram, In the procedure sectio...

In the procedure section, it is important to have a clear circuit diagram with component values and a brief, but accurate description of each step taken. 1. Tables for both the

Laplace transforms, There actually isn't all that much to this section. All...

There actually isn't all that much to this section. All we are going to do now is work a quick illustration using Laplace transforms for a 3 rd order differential equation therefo

Unix help, need a command to : Display user id, first and last names of all...

need a command to : Display user id, first and last names of all the students the class specified by the prefix in alphabetical order by last name from /etc/passwd

Mathematical expression of linear programming problem, A Consultant Dietici...

A Consultant Dietician provides diet and nutritional advice to clients. A client's diet requires that all the food s/he eats come from one of the four "basic food groups" (chocolat

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd