Matlab using the linear regression and linear fitting to find the relationship between the two functions

Source: Internet
Author: User
Tags sprintf
T=[1999 2000 2001 2002 2003 2004 2005 2006 2007 2008]
c=[399.72 506.97 754.98 989.4 1202.48 1473.29 1525 1717.87 1911.45 2004.25]

Find T expression C.


Figure
T=[1999 2000 2001 2002 2003 2004 2005 2006 2007 2008];
c=[399.72 506.97 754.98 989.4 1202.48 1473.29 1525 1717.87 1911.45 2004.25];
A=polyfit (t,c,2);
ti=1999:1:2008;
Ci=polyval (A,ti);
Plot (t,c, ' go ', ' markeredgecolor ', ' k ', ' markerfacecolor ', ' g ', ' markersize ', 6);
Xlabel (' year ');
Ylabel (' relevant data ');
Axis ([1999 2008 2100]) Hold on plot (Ti,ci, ' linewidth ', 2, ' Markersize ',) Legend (' Raw data points ', ' fitted Curves ') plot (T,c, ' r. ') sprintf (' Curve equation: c=%0.5g*t^2+ (%0.5g) *t+ (%0.5g) ', a (1), A (2), A (3))% curve equation: c=-5.5245*t^2+ (22324) *t+ ( -2.255e+007)%
This is 2 times linear correlated figure;
T=[1999 2000 2001 2002 2003 2004 2005 2006 2007 2008];
c=[399.72 506.97 754.98 989.4 1202.48 1473.29 1525 1717.87 1911.45 2004.25];
A=polyfit (t,c,1);
ti=1999:1:2008;
Ci=polyval (A,ti);
Plot (t,c, ' go ', ' markeredgecolor ', ' k ', ' markerfacecolor ', ' g ', ' markersize ', 6);
Xlabel (' year ');
Ylabel (' relevant data '); Axis ([1999 2008 2100]) Hold on plot (Ti,ci, ' linewidth ', 2, ' Markersize ',) Legend (' Raw data points ', ' fitted Curves ') plot (T,c, '-R. ') sprintf (' Curve equation: c=+ (%0.5g) *t+ (%0.5g) ', a (1), A (2),)% curve equation: c=+ (187.66) *t+ ( -3.7473e+005)% This is a linear correlation 


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.