Project

Curve Fitting of temperature and specific heat variation

%curve fitting of temperature vs specific heat
clear all
close all
clc
%load the data which contains variation of specific heat with temperature
temp_cp=load(\'data\');

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




%%curve fit
%%cp=a*t^2+b*t+c

coeff=polyfit(temperature,cp,2);
predicted_cp=polyval(coeff,temperature);

%plotting the data
figure(1)
title(\'Second Order Fit\')
hold on
xlabel(\'Temperature [K]\',\'color\',\'r\')
ylabel(\'Specific Heat [KJ/Kg-K]\',\'color\',\'r\')
plot(temperature,cp,\'linewidth\',1,\'color\',\'g\')
plot(temperature,predicted_cp,\'linewidth\',1,\'color\',\'r\')
legend(\'Original data set\',\'curve fit\')
grid on


%using third order polynomial
coeff_3=polyfit(temperature,cp,3)
predicted_cp1=polyval(coeff_3,temperature)
figure(2)
title(\'Third Order Fit\')
hold on
plot(temperature,cp,\'linewidth\',1,\'color\',\'g\')
plot(temperature,predicted_cp1,\'linewidth\',1,\'color\',\'r\')
xlabel(\'Temperature [K]\',\'color\',\'r\')
ylabel(\'Specific Heat [KJ/Kg-K]\',\'color\',\'r\')
legend(\'Original data set\',\'curve fit\')


 

To get more smooth curve fit we can use higher order polynomials or splitwise polynomials which means using differents polynomials for different range of temperatures.

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.