How can I interpolate a graph with 3 nodes?
Show older comments
I have developed an RRT code that creates a simplified path from one node to another, and I need to smooth it using splines or any other way possible, the code that interpolates the nodes is:
function map_update(vertices,path)
[~, pathCount] = size(path);
for ii = 1 : pathCount - 1
plot([vertices(path(ii), 1), vertices(path(ii + 1), 1)], ...
[vertices(path(ii), 2), vertices(path(ii + 1), 2)], ...
'r', 'LineWidth', 2);
% Creation of spline
h=0:0.1:50;
t=spline([vertices(path(ii), 1), vertices(path(ii + 1), 1)], ...
[vertices(path(ii), 2), vertices(path(ii + 1), 2)], ...
h);
hold on
plot([vertices(path(ii), 1), vertices(path(ii + 1), 1)], ...
[vertices(path(ii), 2), vertices(path(ii + 1), 2)], ...
h,t);
end
end
However this gives me the following picture:

How can I make this interpolation go through the nodes with one line instead of creating two separate lines?
And is if it is possible, how can I make it work in the case I change the start and end locations?
Thank you
Accepted Answer
More Answers (0)
Categories
Find more on Interpolation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!