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

DeepCool launches frameless RGB fans that you can control over Wi-Fi

You can use your smartphone to adjust the speed and lighting of these fans.   Fans are not overly complicated for fancy devices. They have blades that spin and push (or pull) air, and some of them light up. DeepCool has taken things a step further, however, by designing frameless RGB smart fan set that hooks into your wireless network. DeepCool's new MF120 set comes with three fans and a controller for them to plug into to. Using a free app that is available for Android and iOS, you can then connect to the controller and cycle through five built-in lighting effects (dynamic, static, breathing, comet, and fashion collision) and 36 interchangeable lighting modes, and also adjust the speed. We're not sure there is a whole lot of utility for controlling your case's fans with your smartphone, but if that's something you want to do, there you go. The fans themselves are uniquely designed. They're frameless in the sense that they don't sit enclosed in a traditional fra...

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

Best PC Configuration under Rs 25000

  Lately I've been getting a lot of queries regarding PC configurations across various price ranges and since the ones I've posted earlier are quite obsolete now I thought why not to roll out a series of configurations to meet all your demands and to keep up with time. Today I'll be posting a PC configuration under Rs 25000 as this is not only the most popular budget segment but also is the bare minimum you need to get yourself an up to date configuration. Before I proceed further I'd like to mention a few points to give you a clear picture as to what to expect from this configuration - This configuration is aimed at daily to office use along with helping school kids for their school project etc The build should be future proof and should last the user for over a year or two without any upgrade. Upgrade should be easy and economical with minimum change of components. It should be balanced over all with all the components in sync & at par without overpowering or unde...