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

Simple code writing?

  1. Apr 14, 2012 #1
    attachment.php?attachmentid=46216&d=1334416456.jpg

    As for the exercise above here is my attempt:


    Code (Text):
    function c=wregress(x,y,sy)
    a=[x.^2]
    b=[sy.^2]
    A=[sum(a\b) sum(x\b); sum(x\b) sum(1\b)]
    d=(x.*y)
    B=[sum(d\b);sum(y\b)]
     
    c=A\B
    attachment.php?attachmentid=46217&stc=1&d=1334416789.jpg


    When I use the test code given above,

    I get this plotting:

    attachment.php?attachmentid=46219&stc=1&d=1334416946.jpg

    which doesnt seem right to me....or is it?

    Im assuming the fitted line is a line of best fit??

    If there is any mistake on the code can you please help?
     

    Attached Files:

    • 1.JPG
      1.JPG
      File size:
      32.1 KB
      Views:
      89
    • 2.JPG
      2.JPG
      File size:
      20.6 KB
      Views:
      80
    • 3.jpg
      3.jpg
      File size:
      9.7 KB
      Views:
      73
  2. jcsd
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

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



Similar Discussions: Simple code writing?
  1. MATLAB simple code (Replies: 4)

Loading...