rendered paste body%Q1
close all
clear all
t = [2.0 2.2 2.4 3.3 3.5 3.7 3.9 4.5 4.8 5.0];
x = [120 130 130 140 140 130 140 150 160 170];
y = [100 180 200 180 150 180 200 220 240 250];
% cubic spline
PX = spline(t,x);
PY = spline(t,y);
% evalute the splines and then plot
T = linspace(2.0, 5.0, 100);
figure
plot(x,y,'o'); hold on
plot(ppval(PX,T),ppval(PY,T),'r-');
%Q2
% Data for HW 6, Problem 2
% Part a:
%t = [2.0 2.33 2.67 3.0 3.33 3.67 4.0 4.33 4.67 5.0];
% Part b:
%t = [2.0 2.8 3.1 3.4 3.48 3.52 3.6 3.9 4.2 5.0];
% Part c:
%t = [2.0 2.2 2.42 2.66 2.92 3.21 3.53 3.88 4.21 5.0];
x = [120 130 130 140 140 130 140 150 160 170];
y = [100 180 200 180 150 180 200 220 240 250];
PX = spline(t,x);
PY = spline(t,y);
T = linspace(2, 5, 100);
figure
plot(x,y,'o'); hold on
plot(ppval(PX,T),ppval(PY,T),'r-');45
t = [0 1 2 3 4 5 6 7];
x = [0 100 0 0 100 0 0 100];
y = [0 0 0 100 100 100 200 200];
PX = spline(t,x);
PY = spline(t,y);
T = linspace(0, 7, 100);
figure
plot(x,y,'o'); hold on
plot(ppval(PX,T),ppval(PY,T),'r-');45