Viewing 1 post (of 1 total)
  • Author
    Posts
  • #359
    admin
    admin
    Keymaster

    Least-squares fit of data to y = c(1)*x + c(2)

    %  linefit.m
    % @shortDesc: Least-squares fitting
    % @fullDesc: Least-squares fit of data to y = c(1)*x + c(2)
    function c = linefit(x,y)
      x=x(:);
      y=y(:);
      A=[x ones(size(x))];
      c=(A'*A)\(A'*y);
    end
    Attachments:
    You must be logged in to view attached files.
Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.