hi i'm not sure how to start this program.


The program is:

to take in a set of x and y data, perform the least squares regression, and use the coefficients to predict values for the x values given and print the x, y and predicted y values.

Input should come from A FILE in the form: x y. The x-values should be read in to one floating point array and the y-values into another floating point array, so that the array index (element) identifies the dependent (y) and independent (x) values that belong together. For example, the first x, y values will be stored in position (or element, or index) 1 in each of the array of x values and array of y values. Reading of the values should be accomplished using a function called in the following way:


[fXValues, fYValues, iNValues] = readXYPairs(FIDIn)

Could you give us a code sample of what you have done so far, it might get some MatLab experts interested.

your problem is simple, first use "load" functiom to load both of your files (for x and y) then you can use "polyfit" function to perform the least square regression and you are all set. in case you have not used "polyfit" before:

polyfit finds the coefficients of a best-fit polynomial of any required degree. The following codes tries to fit a degree 3 polynomial to a sin curve
x=1:10; y=sin(x); [P,S] = polyfit(x,y,3); yfit= polyval(P,x); %Now compare y with yfit plot(x,y,x,yfit);you may also like to visit kluid (http://www.kluid.com), it is the matlab forum from where, I generally take help on matlab.

b4 : ]


hi i'm not sure how to start this program.

The program is:

to take in a set of x and y data, perform the least squares regression, and use the coefficients to predict values for the x values given and print the x, y and predicted y values.

Input should come from A FILE in the form: x y. The x-values should be read in to one floating point array and the y-values into another floating point array, so that the array index (element) identifies the dependent (y) and independent (x) values that belong together. For example, the first x, y values will be stored in position (or element, or index) 1 in each of the array of x values and array of y values. Reading of the values should be accomplished using a function called in the following way:


[fXValues, fYValues, iNValues] = readXYPairs(FIDIn)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.