Project

Report on curve fitting

Title: Curve fitting.

Aim: Using given thermodynamic data match the curve as from the data with minimum errors.

Objective of the project:

  1. Predict the correct degree of equation for the given thermodynamic data.
  2. The distance between actual graph and predicted graph should be minimum as such as possible.

Procedure:

  1. Load the data file.
  2. Assigned the variables.
  3. Split the data in 4 equal parts.
  4. Make code for each part and made separate figure window for each.
  5. The written code is given as below.

clear all

close all

clc

cp_data = load('data');

temperature = cp_data(:,1);

cp = cp_data(:,2);

cp1=cp(1:800);

temperature1=temperature(1:800);

% Curve fit

% cp = a*T^2 + b*T + c

co_effs1 = polyfit(temperature1,cp1,2);

predicted_cp1 = polyval(co_effs1, temperature1);

figure(1)

% Compare my curve fit with the original data

plot(temperature1, cp1, 'linewidth',3);

xlabel('Temperature [K]');

ylabel('specific heat [KJ/Kmol_K]');

hold on

plot(temperature1, predicted_cp1,'linewidth' ,3, 'color','r');

cp_data = load('data');

temperature = cp_data(:,1);

cp = cp_data(:,2);

cp2=cp(800:1600);

temperature2=temperature(800:1600);

% Curve fit

% cp = a*T^2 + b*T + c

co_effs2 = polyfit(temperature2,cp2,2);

predicted_cp2 = polyval(co_effs2, temperature2);

figure(2)

% Compare my curve fit with the original data

plot(temperature2, cp2, 'linewidth',3);

xlabel('Temperature [K]');

ylabel('specific heat [KJ/Kmol_K]');

hold on

plot(temperature2, predicted_cp2,'linewidth' ,3, 'color','r');

cp_data = load('data');

temperature = cp_data(:,1);

cp = cp_data(:,2);

cp3=cp(1600:2400);

temperature3=temperature(1600:2400);

% Curve fit

% cp = a*T^2 + b*T + c

co_effs3 = polyfit(temperature3,cp3,2);

predicted_cp3 = polyval(co_effs3, temperature3);

figure(3)

% Compare my curve fit with the original data

plot(temperature3, cp3, 'linewidth',3);

xlabel('Temperature [K]');

ylabel('specific heat [KJ/Kmol_K]');

hold on

plot(temperature3, predicted_cp3,'linewidth' ,3, 'color','r');

cp_data = load('data');

temperature = cp_data(:,1);

cp = cp_data(:,2);

cp4=cp(1600:2400);

temperature4=temperature(1600:2400);

% Curve fit

% cp = a*T^2 + b*T + c

co_effs4 = polyfit(temperature4,cp4,2);

predicted_cp4 = polyval (co_effs4, temperature4);

figure(4)

% Compare my curve fit with the original data

plot(temperature4, cp4, 'linewidth',3);

xlabel('Temperature [K]');

ylabel('specific heat [KJ/Kmol_K]');

hold on

plot(temperature4, predicted_cp4,'linewidth' ,3, 'color','r');

Error while writing a code:

  1. If we try to write a code for a full data in a one graph then there is huge possibility of getting error.
  2. To overcome this type of error and matching the curves I split the data in 4 equal parts.
  3. And wrote the separate code for each.

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.