CURVE FIT
clear all
close all
clc
% preparing data
cpdata=load(\'data\');
temp=cpdata(:,1);
cp=cpdata(:,2);
% curve fit
%cp=a*t+c
coeffs=polyfit(temp,cp,1);
predictedcp=polyval(coeffs,temp);
%compare curve fit with original data
plot(temp,cp,\'linewidth\',3);
hold on
plot(temp,predictedcp,\'linewidth\',3,\'color\',\'r\');
xlabel(\'temp in k\');
ylabel(\'specific heat in kj/kmol-k\');
legend(\'original dataset\',\'curve fit\')
clear all
close all
clc
% preparing data
cpdata=load(\'data\');
temp=cpdata(:,1);
cp=cpdata(:,2);
% curve fit
%cp=a*t^3+b*t^2+c*t+d
coeffs=polyfit(temp,cp,3);
predictedcp=polyval(coeffs,temp);
%compare curve fit with original data
plot(temp,cp,\'linewidth\',3);
hold on
plot(temp,predictedcp,\'linewidth\',3,\'color\',\'r\');
xlabel(\'temp in k\');
ylabel(\'specific heat in kj/kmol-k\');
legend(\'original dataset\',\'curve fit\')
reduce the degree of the
polynomial, or try centering and scaling as described in HELP POLYFIT.