Project

Curve Fitting

clear all
close all
clc

cp_data=load(\'data\');

temperature=cp_data(:,1);
cp=cp_data(:,2);

co_eff=polyfit(temperature,cp,3);
predicted_cp=polyval(co_eff,temperature);

plot(temperature,cp,\'linewidth\',3)
hold on

plot(temperature,predicted_cp,\'linewidth\',3,\'color\',\'r\')

xlabel(\'temperature\')

ylabel(\'specific heat\')

\"\"

\"\"

By givingthe degree of polynomial=2, the curve follow the general path of actual curve but do not fit the curve with accuracy.

to get a more accurate curve, we have to increase the degree of polynomial to 3.

and as the image depicts, the results with degree3 polynomial are much better than that with degree2.

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.