MATLAB: Curve interpolation problem

interpolation

Hello, I have a project in the university to make a video of a car moving by a road defined by the user with the ginput() function. I can make this.. but the curve that the car is moving needs to be smoothed. So I tryed the 'basic fitting' tools and some more functions but the moving line is almost a closed curve… so I can`t make a smooth curve based on the poinst of the user input.
Can some one help me?! Here is an example of a user defined curve:
XX=[100.0000 167.3203 359.0253 410.6382 585.7535 716.6290 712.9424 476.9977 364.5553 185.7535 100.9608 86.2143];
YY=[150.0000 59.9470 107.8733 242.4355 100.5000 235.0622 441.5138 423.0806 529.9931 533.6797 364.0945 170.5461];
plot(XX,YY,'b-');

Best Answer

Maybe something like this?
XX=[100.0000 167.3203 359.0253 410.6382 585.7535 716.6290 712.9424 476.9977 364.5553 185.7535 100.9608 86.2143];
YY=[150.0000 59.9470 107.8733 242.4355 100.5000 235.0622 441.5138 423.0806 529.9931 533.6797 364.0945 170.5461];
plot(XX,YY,'b');
f = 10;
XXf = interpft(XX,numel(XX)*f);
YYf = interpft(YY,numel(YY)*f);
hold all;
plot(XXf(1:end-f+1),YYf(1:end-f+1),'r');