How to upsample (increase) 2d points with interpolation

37 vues (au cours des 30 derniers jours)
aposta95
aposta95 le 31 Mai 2022
Commenté : Voss le 31 Mai 2022
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!

Réponse acceptée

Voss
Voss le 31 Mai 2022
Modifié(e) : Voss le 31 Mai 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)
  2 commentaires
aposta95
aposta95 le 31 Mai 2022
Thanks a lot! You saved my day :)
Voss
Voss le 31 Mai 2022
You're welcome!

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by