Spline interpolation, given a data set representing 6 points (xy-axis) of a snake's position at a given time
Mostra commenti meno recenti
I'm currently working on a spline approximation. I am given t = t1, t2, t3, t4, where I am given a data set representing 6 points (xy-axis) of a snake's position at a given time. My assignment is to plot these 6 points using a spline approximation (interpolation).
My code currently look like this:
% t=[30,170,230 ,385]
x30 = xsnake(30,:);
x170 = xsnake(170,:);
x230 = xsnake(230,:);
x385 = xsnake(385,:);
x = [x30, x170, x230, x385]';
y30 = ysnake(30,:);
y170 = ysnake(170,:);
y230 = ysnake(230,:);
y385 = ysnake(385,:);
y = [y30, y170, y230, y385]';
xx = linspace(0,3.2,100);
plot(xx,csapi(x,y,xx),'k-',x,y,'ro')
The problem is however that I was now told to split this up to 4 different "plot" but on the same graf--I would like to have 4 "spline approximations" on the same graph in different colors. How do I do this? My first attempt was something like this:
plot(xx,csapi(x30,y30,x170,y170,x230,y230,x385,y385,xx),'k-',x,y,'ro')
I have however never used csapi before so I am unfamiliar how to apply it or how to even separate the lines with different colors. My attempt was clearly wrong as I got the error message "too many inputs". Any feedback/suggestions?
Regards, Christoffer
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Spline Postprocessing in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!