All Courses
All Courses
Courses by Software
Courses by Semester
Courses by Domain
Tool-focused Courses
Machine learning
POPULAR COURSES
Success Stories
AIM: CURVE FITTING USING MATLAB OBJECTIVE: 1. Linear and cubic polynomial curve fitting to a set of data points. 2. Plotting predicted curves against raw data points. 3. Studding parameters that measure the goodness of a fit THEORY: Curve fitting is the process of constructing a curve or mathematical function, that has…
Ashutosh Kumar
updated on 07 May 2020
AIM: CURVE FITTING USING MATLAB
OBJECTIVE:
1. Linear and cubic polynomial curve fitting to a set of data points.
2. Plotting predicted curves against raw data points.
3. Studding parameters that measure the goodness of a fit
THEORY:
Curve fitting is the process of constructing a curve or mathematical function, that has the best fit to a series of data points. Fitted curves can be used as an aid for data visualization, to infer values of a function where no data are available, and to summarize the relationships among two or more variables. By curve fitting, we can capture the trend in the data and make predictions of how the data series will behave in the future.
Types of curve fitting include:
Linear and Polynomial Curve Fitting :
Linear curve fitting, or linear regression, is when the data is fit to a straight line. A straight line provides a reasonable enough fit to make predictions.
Since the equation of a generic straight line is always given by,
f(x)= ax + b, equation for linear curve fitting
The goal is to identify the coefficients a' and 'b' such that f(x) 'fits' the data well.
How to find coefficients for best fit?
Considering the vertical distance from each point to a prospective line as an error, and summing them up over our range, gives prospective line is. A line that provides
us a concrete number that expresses how far from 'best' the a minimum error can be considered the best straight line.
Since it's the distance from our points to the line we're interested in whether it is positive or negative distance is not relevant-we square the distance in our error calculations. This also allows us to weight greater errors more heavily. So this method is called the least-squares approach.
Polynomial curve fitting is when we fit our data to the graph of a polynomial function. The same least-squares method can be used to find the polynomial, of a given degree, that has a minimum total error .
PROGRAM
clear all
close all
clc
%prepare the data
cp_data = load('data');
temperature = cp_data(:,1);
cp = cp_data(:,2);
co_effs = polyfit(temperature,cp,1);
predicted_cp = polyval(co_effs,temperature);
figure(1)
plot(temperature, cp,'linewidth',3)
hold on
plot(temperature,predicted_cp,'linewidth',3)
xlabel('temperature [k]')
ylabel('specific heat [kj/kmol-k]')
title('linear')
legend('original dataset','curve fit')
co_effs = polyfit(temperature,cp,3);
predicted_cp = polyval(co_effs,temperature);
figure(2)
plot (temperature,cp,'linewidth',3)
hold on
plot(temperature,predicted_cp,'linewidth',3)
xlabel('temperature [k]')
ylabel('specific heat [kj/kmol-k]')
title('cubic')
legend('original dataset','curve fit')
ERROR FACED : no error encounterd
RESULT :
Plot for linear
Plot for cubic
COCULUSION :
from the above plot, we can clearly say that the cubic curve is clearly fits better compare than the linear curve.
But if we increase the order 4 5 6 we might get a much better fit than cubic and to know which order of polynomial fits the best we have to error check by RMSE lower the RMSE the better the curved fit.
Leave a comment
Thanks for choosing to leave a comment. Please keep in mind that all the comments are moderated as per our comment policy, and your email will not be published for privacy reasons. Please leave a personal & meaningful conversation.
Other comments...
Section Modulus calculation and optimization
Objective: Using the Section from the Hood design and calculate the section modulus and compare it with a new section with a higher sectional modulus for optimization. Introduction: Section Modulus - Section modulus is a direct measure of the strength of any sectional area of an object about a reference axis(neutral…
30 Oct 2021 02:55 PM IST
Fender Design Challenge
Objective : Design a front fender from the given skin data and the master section provided with Drip mounting, A-pillar, Sill, Bumper, C mounting, and Splash mountings. Consider the front fender of a car that satisfies the manufacturing as well as functional requirements. To understand the design engineering principles…
13 Jun 2021 06:57 PM IST
Coin Holder Design
Objective : To design coin holder as per automotive OEM Standard. Create B Class and C Class and tooling axis. Convert close lose the surface into the solid body and provide the thickness of 2.5mm. Performing draft analysis to verify the creation of the Tooling axis and C Class surface. Software : CATIA V5 (Generative…
06 Jun 2021 08:39 PM IST
Centrifugal pump design and analysis Using SOLIDWORKS
Click here for Flowbench Analysis Abstract In this Project, Creating a 3D model of a Centrifugal pump, run a baseline flow simulation where inlet flow takes place and then perform a parametric study for different velocities. Showing the Performance diagram and Obtain the relationship between Pressure ratio and mass…
20 May 2021 08:43 AM IST
Related Courses
Skill-Lync offers industry relevant advanced engineering courses for engineering students by partnering with industry experts.
© 2025 Skill-Lync Inc. All Rights Reserved.