Chuyển đến nội dung chính

Machine learning Curve fitting using MATLAB

here is the code for the data set we have taken.



>> clear;
close all;
Tx = [80: -20: -340];
alphay=[6.47  6.36 6.24 6.12 6.00 5.86 5.72 5.58 5.43 5.28 5.09 4.91 4.72 4.52 4.30 4.08 3.83 3.58 3.33 3.07 2.76 2.45];
alphay=1.e-6*alphay;
plot(Tx,alphay,'bo');


title('Thermal expansion cofficient of steel');
ylabel('cofficient\alpha');
xlabel('temperature(in F)');
>> coef1=polyfit(Tx,alphay,1)



coef1 =

   1.0e-05 *

    0.0009    0.6025

>> coef1=polyfit(Tx,alphay,2)

coef1 =

   1.0e-05 *

   -0.0000    0.0006    0.6015

>> coef1=polyfit(Tx,alphay,3)

coef1 =

   1.0e-05 *

    0.0000   -0.0000    0.0006    0.5998

>> pred1=polyval(coef1,Tx);
>> pred2=polyval(coef2,Tx);
Undefined function or variable 'coef2'.

Did you mean:
>> coef1=polyfit(Tx,alphay,1)

coef1 =

   1.0e-05 *

    0.0009    0.6025

>> coef2=polyfit(Tx,alphay,2)

coef2 =

   1.0e-05 *

   -0.0000    0.0006    0.6015

>> coef3=polyfit(Tx,alphay,3)

coef3 =

   1.0e-05 *

    0.0000   -0.0000    0.0006    0.5998

>> pred1=polyval(coef1,Tx);
>> pred2=polyval(coef2,Tx);
>> pred3=polyval(coef3,Tx);
>> [pred1; pred2; pred3]

ans =

   1.0e-05 *

  Columns 1 through 7

    0.6776    0.6588    0.6400    0.6213    0.6025    0.5837    0.5649
    0.6432    0.6342    0.6243    0.6134    0.6015    0.5886    0.5748
    0.6467    0.6357    0.6243    0.6123    0.5998    0.5866    0.5727

  Columns 8 through 14

    0.5462    0.5274    0.5086    0.4898    0.4711    0.4523    0.4335
    0.5599    0.5441    0.5273    0.5095    0.4907    0.4710    0.4502
    0.5581    0.5426    0.5264    0.5092    0.4910    0.4719    0.4517

  Columns 15 through 21

    0.4147    0.3960    0.3772    0.3584    0.3397    0.3209    0.3021
    0.4285    0.4058    0.3821    0.3574    0.3318    0.3052    0.2776
    0.4303    0.4078    0.3841    0.3592    0.3328    0.3052    0.2760

  Column 22

    0.2833
    0.2490
    0.2455

>> hold on
>> plot(tx,pred1)
Undefined function or variable 'tx'.

Did you mean:
>> plot(Tx,pred1)
>> plot(Tx,pred2,'r')
>> plot(Tx,pred3,'k--')
>> legend({'Data' 'Linear' 'Quadratic' 'Cubic'}, 'Location', 'Northwest')
>> hold off
>>

Nhận xét

Popular Posts

Apple Watch Series 3 38mm Space Gray Case Black Sport Band GPS + Cellular

Apple Watch Series 3 38mm Space Gray Case Black Sport Band GPS + Cellular Price : 194.99 Ends on : 5 days View on eBay

Episode 100 - Podcasting is Dead

It’s Friday, October 30th, 2009 and welcome to episode 101 of TechTalk4Teachers! In this episode: Podcasting with 3rd Graders, an interview with Mrs. Judy Barford, Early Childhood, Elementary, and Middle Level Education Department at Eastern Illinois University Right Click Here to Download MP3 Show notes for Episode 100: Leo LaPorte’s Comment – Podcasting is Dead http://onlinedesignbureau.com/blog/116-social-media-marketing/498-leo-laporte-declares-podcasting-dead You can fast forward in the video embedded at this website to the 16 minute and 30 second mark to go directly to the “Podcasting is Dead” comments Leo made at the Online Media Association conference on October 4, 2009. No More Podcast in The New Media Expo – 2007 Podcasting is Dead Comment http://mwgblog.com/archives/2007/10/01/no-more-podcast-in-the-new-media-expo/ Also in this episode are the comments from three grad students regarding a recent podcasting assignment where the students gave their thoughts about listening t...

Episode 136 - We have the technology and we can use it

Episode 136 - We have the technology and we can use it It’s Friday, September 14, 2012 and welcome to episode 136 of Tech Talk for Teachers. I’m Cindy Rich and I’m Tom Grissom. We are changing things up a little bit. TechTalk4Teachers is moving to a bi-monthly format.     Right Click Here to Download MP3 (36 minutes 29 seconds) In this episode we talk about the all the technology available for teachers and students to use to create amazing projects. We also have a couple of useful Technology Picks of the Week. Technology Pick of the Week Tom's Pick Wacom Bamboo Pen and Touch USB Slate http://www.wacom.com/en/products/bamboo/bambootablets.aspx Cindy's Pick Hero GoPro Caneras http://gopro.com/ Keep on Learning!