Derek Rampal
10/05/2008
HW 10
18a.
%
%
Main script
%
xpts = zeros(5,1);
xpts = [0;3;5;8;13];
ypts = zeros(7,1);
ypts = [75;0;225;383;623;993;72];
S=cubic_spline_get_coeffs(xpts,ypts);
xeval = zeros(1,1);
xeval = [10];
y = cubic_spline_evaluate (xeval,S,xpts);
y
Output:
y =
774.8384
18b c and d.
I wasnt thinking and i rewrote code without having to
....
Code:
%
%
Derek Rampal HW 10
%
Main script
%
format
long
;
xpts = zeros(5,1);
xpts = [0;3;5;8;13];
xlen = length(xpts);
ypts = zeros(7,1);
ypts = [75;0;225;383;623;993;72];
xeval = zeros(1,1);
xeval = [10];
S = cubic_spline_get_coeffs(xpts,ypts);
Sp = splined(S);
Spp = splined(Sp);
tolerance = 1e-5;
[ap1,bp1] = brutes(Sp, xpts, 1, tolerance, 3,55*5280/3600);
[ap2,bp2] = brutes(Sp, xpts, 2, tolerance, 3,55*5280/3600);
[ap3,bp3] = brutes(Sp, xpts, 3, tolerance, 3,55*5280/3600);
[ap4,bp4] = brutes(Sp, xpts, 4, tolerance, 3,55*5280/3600);
ap1
This
preview
has intentionally blurred sections.
Sign up to view the full version.
bp1
ap2
bp2
ap3
bp3
ap4
bp4
[app1,bpp1] = brutes(Spp, xpts, 1, tolerance, 3,0);
[app2,bpp2] = brutes(Spp, xpts, 2, tolerance, 3,0);
[app3,bpp3] = brutes(Spp, xpts, 3, tolerance, 3,0);
[app4,bpp4] = brutes(Spp, xpts, 4, tolerance, 3,0);
app1
bpp1
app2
bpp2
app3
bpp3
app4
bpp4
y = cubic_spline_evaluate ((app3+bpp3)/2,Sp,xpts);
(ap3(1,1)+bp3(1,1))/2
(ap3(1,2)+bp3(1,2))/2
(app3+bpp3)/2
y
function
Sprime=splined(S)
%
%

This is the end of the preview.
Sign up
to
access the rest of the document.
- Spring '09
- ford
- Spline interpolation, Derek Rampal, Xpts
-
Click to edit the document details