Project

CURVE FITTING

AIM:

To simulate curve fitting for specific heat in linear and cubic polynomial.

OBJECTIVE:

  • To write code to fit a linear and cubic polynomial for the Cp data.
  • To plot the linear and cubic fit curves along with the row data points.
  • To explain the parameters used to measure the fitness characteristics for both the curves

THEORY:

Curve fitting is a process of constructing a curve or mathematical function that has the best fit to a series of data points possibly subject to constraints.Curve fitting can involve either interpolation , where an exact fit to the data is required or soothing in which smooth function is constructed that aproximately fit the data.A related topic is regression analysis whish focus more on questions of statistical interferance such as how much uncertenity is present in a curve that is fit to data observed with random errors.Fitted curves can be used as an aid for data visualisation to infer values of a function where no data are available and to summarise relationship among two0 or more variable.Extrapolarion refers to the fitted to the curve beyond the range of the observed data and is subjected to a degree of uncertenity since it may reflect the method used to construct the curve as much as it reflecte the observed data.

MATHEMATICAL EQUATION:

for linear polynomial

ax+b=0

for cubic polynomial

`ax^3+bx^2+cx+d=0`

To minimize the error between predicted super heat and original super heat

RMSE=`sqrt(sum((c_p-predicted c_p)^2)`

PROGRAM FOR CURVE FITTING:

Linear Polynomial

clear all
close all
clc

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

%plotting
plot(temperature,cp,'linewidth',3)
xlabel('teperature[K]')
ylabel('specific heat[KJ/Kmol-K]')

%curve fit
co_efficient=polyfit(temperature,cp,1);
predicted_cp=polyval(co_efficient,temperature);

%comparing and plotting
hold on
plot(temperature,predicted_cp,'linewidth',3,'color','r')
legend('original dataset','curve fit')

Cubic Polynomial

clear all
close all
clc

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


%curve fit
co_efficient1=polyfit(temperature,cp,1);
predicted_cp1=polyval(co_efficient1,temperature);

co_efficient3=polyfit(temperature,cp,3);
predicted_cp3=polyval(co_efficient3,temperature);

    

%comparing and plotting

plot(temperature,cp,'linewidth',3)
hold on
plot(temperature,predicted_cp1,'linewidth',3,'color','r')
plot(temperature,predicted_cp3,'linewidth',3,'color','g')
xlabel('teperature[K]')
ylabel('specific heat[KJ/Kmol-K]')
legend('original dataset','curve fit')
grid on
 rmse_1=sqrt(mean((cp-predicted_cp1).^2))
 rmse_2=sqrt(mean((cp-predicted_cp3).^2))

OUTPUT:

Linear Polynomial

Cubic Polynomial:

ERRORS AND CORRECTION:

This is nat an error but warning because of the line exceeds than the graph.

RESULT:

  • Curve fitting in cubic and linear polynomial is simulated.
  • Graph is plotted.
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.