How to upsample (increase) 2d points with interpolation

22 views (last 30 days)
Hi, I want to upsampling 2d points (x,y) with interpolation.
Variable 'pts' contains 4x2 points (plot below), and I want to increase it to 1009x2 points, and the shape of 2d plot should not be changed.
I tried interp1 as below, but it changes the overall shape of plot.
load points
figure; plot(pts(:,1),pts(:,2))
vr = linspace(min(pts(:,1)), max(pts(:,1)), 1009);
ve = linspace(min(pts(:,2)), max(pts(:,2)), 1009);
B = interp1(1:length(pts(:,1)),pts(:,1),vr);
C = interp1(1:length(pts(:,2)),pts(:,2),ve);
plot(B,C)
How can I increase points of x, y without changing the shape of plot?
Maybe I think using interp2 would help, but I didn't understand the logic..
I attached a data, so please take a look at it!

Accepted Answer

Voss
Voss on 31 May 2022
Edited: Voss on 31 May 2022
load points
figure;
plot(pts(:,1),pts(:,2),'LineWidth',6)
hold on
n = size(pts,1);
BC = interp1(1:n,pts,linspace(1,n,1009));
plot(BC(:,1),BC(:,2),'.r','MarkerSize',3)

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!