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: Comparing least square equations in matlab

  1. Apr 22, 2012 #1
    The function should accept the input arrays x and y and to process the data using
    linear, semilogy, and log‐log least squares fits to determine which is the best. For this problem, the "best" is given by the smallest value. I wrote the individual scripts for each for the different equations, but I wasn't sure how to compare them to each other in Matlab. Any help would be appreciated!

    [a,b,type] = linear_ls2_xxx(x,y)
    % This function creates returns the linear parameters of the
    % slope (a) and y-intercept (b) given a set of input data (x,y).
    % The function attempts to curve fit to linear, semilogy and log-log
    % using natural logarithms.
    % The returned values indicate those with the smallest sum of squared
    % error.
    % Calling parameters
    %... (you fill in)
    % Returned parameters
    %... (you fill in)
    % type flag indicating which type of equation had the best fit
    % type=1 for linear, =2 for semilogy, =3 for log-log
  2. jcsd
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook

Can you offer guidance or do you also need help?
Draft saved Draft deleted