Project

curve fitting

code for curve fitting for cubic polynomial

clear all
close all
clc

%data
cp_data = load(\'data\');
temperature = cp_data(:,1);
cp = cp_data(:,2);

%curve fit

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

%compare curve fit with original data
plot(temperature,cp,\'linewidth\',3)
hold on
plot(temperature,predicted_cp,\'linewidth\',3,\'color\',r\')
xlabel(\'temperature[k]\')
ylabel(\'specific heat[kj/kmol-k]\')
legend(\'original dataset\',\'curve fit\')

Result for cubic polynomial

\"\"

code for curve fitting for linear polynomial

clear all
close all
clc

%data
cp_data = load(\'data\');
temperature = cp_data(:,1);
cp = cp_data(:,2);

%curve fit

co_effs = polyfit(temperature,cp,1);
predicted_cp = polyval(co_effs,temperature);

%compare curve fit with original data
plot(temperatue,cp,\'linewidth\',3)
hold on
plot(temperature,predicted_cp,\'linewidth\',3,\'color\',\'r\')
xlabel(\'temperature[k]\')
ylabel(\'specific heat[kj/kmol-k]\')
legend(\'original dataset\',\'curve fit\')

Result for curve fitting for linear polynomial

\"\"

This program explains about curve fitting of given values. It shows curve fit between temperature and specific heat cp. while using cubic polynominal it shows very bad conditioned. so linear polynominal is used to get curve fit perfect.

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.