Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Homework Help: Curve fitting using matlab

  1. Nov 8, 2008 #1
    1. The problem statement, all variables and given/known data
    For the given set of data, find the least-square curve:
    A) f(x)=Ce^Ax, by using the change of variable X=x, Y=ln(y), and C=e^B to linearize the data points.

    B) f(x) = 1/(Ax+B), by using the change of variable X=x and Y = 1/y to linearize the data points.

    x : [ -1 0 1 2 3]
    y : [ 6.62 3.94 2.17 1.35 0.89]

    I need the matlab code on how to do these 2 problems im confused and which curve gives a better fit. ??

    2. Relevant equations

    This is the only code i know but idk how to do it with the question they are asking i need to pertain it to that

    function C = poly(X,Y,M)
    for k=1:M+1

    3. The attempt at a solution

    These are the coefficients:

    I am confused with what the question is asking i know im suppose to have a ans for part A and B
  2. jcsd
  3. Nov 10, 2008 #2
    Think about what a change of variable is, then figure out how to apply that to the data.

    Aka, when you make a substitution for y=ln(y), that just means you take your y list, and just take the ln of that. That now because the new measurement for what used to be the y-axis.

    Does that make sense?
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook