Project

curve fit

clear all
close all
 clc
 
 
 % Preparing the data
 
 cp_data=load(\'data.txt\');
 temperature=cp_data(:,1);
 cp=cp_data(:,2);
 
 
 % Curve fit
 
 % cp= aT^2 + b*T + c
 coeffs= polyfit(temperature,cp,4);
 
 predicted_cp= polyval(coeffs , temperature);
 
 
 % compare curve fit with original data
 plot(temperature,cp,\'linewidth\',2);
 hold on
 plot(temperature,predicted_cp,\'linewidth\',3,\'color\',\'r\');
xlabel(\'Temperature [K]\');
 ylabel(\'Specific Heat [KJ/Kmol-K]\');
 legend(\'Original data\',\'Curve fit\')



EXPLAINATION
The result i got is for cubic curve which is some what following the original data curve
,it is not very accurate .Thus the result i got is somewhat appropriate.

In order to improve the result we can simply increase the degree of the polynomial,as we increase the degree of polynomial the predicted cp follows the ori=ginal data more accuratly ,thus if we increase the degreee of polynomial then we get better result and at  certain degree it is exactly as original data and increasing the degree results in no changes.  
 
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.