0% found this document useful (0 votes)
16 views2 pages

LSF Parabola

This document contains the details of a Scilab code that performs least squares fitting of data points to a parabolic curve. It provides the roll number, name, and aim of the student who wrote the code. The code defines the x and y coordinates of 10 data points, calculates the necessary sums and matrices, inverts a matrix to determine the coefficients c, d, and e of the parabolic fitting curve y=cx^2+dx+e, and plots the original data points and fitted curve.

Uploaded by

Aditya Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views2 pages

LSF Parabola

This document contains the details of a Scilab code that performs least squares fitting of data points to a parabolic curve. It provides the roll number, name, and aim of the student who wrote the code. The code defines the x and y coordinates of 10 data points, calculates the necessary sums and matrices, inverts a matrix to determine the coefficients c, d, and e of the parabolic fitting curve y=cx^2+dx+e, and plots the original data points and fitted curve.

Uploaded by

Aditya Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Name: Aditya Kumar

Roll no.: 3914

Group: A+B

Scilab Code 6

Aim: Least Square fitting of data points in a


parabola
clc
clear

x=[0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0]
y=[0.33,0.70,1.30,1.90,2.42,3.41,4.02,4.99,5.98,6.95]
$x=0
$y=0
$xy=0
$x2=0
n=length(x)
m=length(y)
if n~=m then
disp("Dimensions of x and y are not same, ABORTING PROGRAM !")
end
$x=sum(x)
$y=sum(y)
$xy=sum(x.*y)
$x2=sum(x^2)
$x3=sum(x^3)
$x4=sum(x^4)
$x2y=sum((x^2).*y)
v=[$x4 $x3 $x2; $x3 $x2 $x; $x2 $x n]
w=[$x2y; $xy; $y]
r=inv(v)*w
disp(r)
c=r(1)
d=r(2)
e=r(3)
disp('The least square fitting curve is= '+string(c)+'*x'+string(d))
plot(x,y,'or')
y=c*(x^2)+d*(x)+e
plot(x,y)
legend(['Data points','Least square fitted curve'])
xtitle('LEAST SQUARE FITTING:PARABOLA','x-axis','y-axis')
Output:

You might also like