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

We are looking for pool services software, We are looking for Pool Services...

We are looking for Pool Services Software Our company Pool Hands LLC is looking to build software for our internal use. We would like the software built therefore that it could

Java project, NOTE: You will only submit the University.java and EmptyFileE...

NOTE: You will only submit the University.java and EmptyFileException.java files (inside P3.zip/tar) NOTE on null objects:. From Project 1: Since the array of students in the Cou

Write a program to read the file, Suppose you have a ?le orase of city and ...

Suppose you have a ?le orase of city and country names, like this: Cluj, Romania Debrecen, Hungary Klagenfurt, Austria Berlin, Germany Szeged, Hungary Budapest, Hungary Lintz, A

Random number generator guessing game, The GuessingGame class contains a sk...

The GuessingGame class contains a skeleton for a program to play a guessing game with the user. The program should randomly generate an integer between 1 and 10 and then ask the us

3-Tier Architecture in asp.net, I am getting error at business layer object...

I am getting error at business layer object in code behind page.

X86 Assembly, You are to Use ASCII operations to design an IA-32 assembly ...

You are to Use ASCII operations to design an IA-32 assembly language program which will do addition and subtraction on positive integers of any length represented in characters. T

Assembly TASM or MASM, I need help with making a assembly program that uses...

I need help with making a assembly program that uses Hoffman''s coding scheme to compress a text file.

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

Padovan string, Padovan String Problem Description A Padovan string...

Padovan String Problem Description A Padovan string P(n) for a natural number n is defined as: P(0) = 'X' P(1) = 'Y' P(2) = 'Z' P(n) = P(n-2) + P(n-3), n

Program for average grades for 10 students, Assume that you are a college p...

Assume that you are a college professor needing to average grades for 10 students. Write a program that asks for each student's name and grade. Print the list on-screen with each s

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