- #1

- 5

- 0

Code:

```
%segment for the S
x1 = [0 2 1 2 3];
y1 = [1 0 2.5 1 3];
[x_t y_t t] = ParametricSpline(x1, y1);
xref = ppval (x_t, t);
yref = ppval(y_t, t);
plot(x1, y1, 'o', xref, yref);
```

Code:

```
function [ x_t, y_t, tt ] = ParametricSpline(x , y)
%ParametricSpline Summary of this function goes here
% Detailed explanation goes here
arc_length = 0;
n = length(x);
t = zeros(n, 1);
for i=2:n
arc_length = sqrt((x(i)-x(i-1))^2 + (y(i)-y(i-1))^2);
t(i) = t(i-1) + arc_length;
end
x_t = spline(t, x);
y_t = spline(t, y);
tt = linspace(1,n,1000);
end
```

When I run this, I get a parametric curve but it doesn't go through all of the points. For some reason it leaves a few out. However, if I don't run a linspace on tt it DOES go through all the points but it isn't a curve, just straight lines connecting the points. Any ideas on what I'm doing wrong?