943,985 Members | Top Members by Rank

Ad:
Mar 1st, 2005
0

matlab program help

Expand Post »
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)
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
default is offline Offline
1 posts
since Mar 2005
Mar 10th, 2005
0

Re: matlab program help

Could you give us a code sample of what you have done so far, it might get some MatLab experts interested.
Moderator
Reputation Points: 1333
Solved Threads: 1403
DaniWeb's Hypocrite
vegaseat is offline Offline
5,792 posts
since Oct 2004
May 11th, 2006
0

Re: matlab program help

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 : ]



Quote originally posted by default ...
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)
Reputation Points: 10
Solved Threads: 1
Light Poster
b4codes is offline Offline
35 posts
since May 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Legacy and Other Languages Forum Timeline: Problem with Qbasic If Then's
Next Thread in Legacy and Other Languages Forum Timeline: Matlab help?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC