{"id":395,"date":"2017-09-14T12:06:34","date_gmt":"2017-09-14T15:06:34","guid":{"rendered":"http:\/\/www.professores.uff.br\/diomarcesarlobao\/?page_id=395"},"modified":"2017-09-14T12:06:34","modified_gmt":"2017-09-14T15:06:34","slug":"linefit-m","status":"publish","type":"page","link":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/linefit-m\/","title":{"rendered":"linefit.m"},"content":{"rendered":"<pre>function linefit(t, b)\r\n\r\n% linefit  Plot the least squares fit by a line.\r\n%\r\n% linefit(t, b), where t and b are vectors of the same length,\r\n% displays the best line fit to the data points (t(i), b(i)).\r\n\r\n% We now insure that t and b are column vectors.\r\nt = t(:); b = b(:);\r\n\r\n% Form the matrix whose first column is all ones and\r\n% whose second column is the vector t.\r\nn = length(t);\r\ne = ones(n, 1);\r\nA = [e t];\r\n\r\n% Solve the least squares problem, A*x ~= b.\r\nxhat = lsq(A, b);\r\nc = xhat(1);\r\nd = xhat(2);\r\n\r\n% Plot the results.\r\ntline = [1.1*min(t)-0.1*max(t), 1.1*max(t)-0.1*min(t)];\r\nyline = c + d*tline;\r\nplot(t,b,'ro',t,c+d*t,'k*',tline,yline,'k-')\r\nif d &gt;= 0 , sign = ' + '; else, sign = ' - '; end\r\ntitle(['Best line is ' num2str(c) sign num2str(abs(d)) '*t.'])\r\nxlabel('t')<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>function linefit(t, b) % linefit Plot the least squares fit by a line. % % linefit(t, b), where t and b are vectors of the same length, % displays the best line fit to the data points (t(i), b(i)). % We now insure that t and b are column vectors. t = t(:); b = [&hellip;]<\/p>\n","protected":false},"author":22,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"categories":[],"tags":[],"class_list":["post-395","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/pages\/395","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/users\/22"}],"replies":[{"embeddable":true,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/comments?post=395"}],"version-history":[{"count":1,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/pages\/395\/revisions"}],"predecessor-version":[{"id":396,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/pages\/395\/revisions\/396"}],"wp:attachment":[{"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/media?parent=395"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/categories?post=395"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/tags?post=395"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}