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

MI5 - Tech Vacancies

MI5 (Security Services) is often overlooked as an organisation that invests in technology. The reality is that we have pioneering corporate and operational technology sections which offer careers in technology that are very different from any other organisation. https://www.mi5.gov.uk/careers/opportunities/technology?adhoc_referrer=011617032006 Also more vacancies here:- https://

Learning from Posters Pt2 - Forensics, Cyber and Security

Part 2 -  Continuing on from Part 1 showing the collection of learning from posters which I thought it would be helpful to the community to have them posted in a single location. Learning from Posters Pt1 - Forensics, Cyber and Securityhttp://trewmte.blogspot.co.uk/2016/06/learning-from-posters-pt1-forensics.html