1) Generate intermediate points in a set of X,Y while respecting the original points order. 2) Generate same number of points for 2 different set of X,Y with different sizes.
Mostra commenti meno recenti
1) Generate intermediate points in a set of X,Y in matlab while respecting the original points order.
2) Generate same number of points for 2 different set of X,Y with different sizes.
I hope my question is clear.
Imagine I have 2 variables with totaly different sizes :
a=[2,1;2,2;1,4;-1,4;-2,1;-2,-2;0,-3;1.5,0];
b = [3,2;3,3;2,5;0,6;-2,5;-3,2;-3,-1;0,-4;2,-2];

I need to generate 2 variables of same dimensions (say 1000 points, Equidistant) from a and b. the first strating with a-start and the second with b-start.
3) I have something like this in 3D but hope an idea to do it for 2D will work also for 3D
Thank you
3 Commenti
Mathieu NOE
il 16 Ott 2025
hello
i am not 100% if you want to interpolate each curve separately , or create a interpolated curve between a and b curves (would need to resample both with same number of points)
Mohamad TOUT
il 16 Ott 2025
Mathieu NOE
il 20 Ott 2025
As always , my pleasure !
Risposta accettata
Più risposte (1)
Alan Stevens
il 16 Ott 2025
Modificato: Alan Stevens
il 16 Ott 2025
Something like this? (I've just used 50 interpolated points for clarity below). Choose your own interpolation type. The "equidistant" below is interpreted as equal angle separation.
a=[2,1;2,2;1,4;-1,4;-2,1;-2,-2;0,-3;1.5,0];
b = [3,2;3,3;2,5;0,6;-2,5;-3,2;-3,-1;0,-4;2,-2];
plot(a(:,1),a(:,2),'ro-',b(:,1),b(:,2),'bs-'),grid
hold on
% convert to polar coordinates
[tha,ra] = cart2pol(a(:,1),a(:,2));
[thb,rb] = cart2pol(b(:,1),b(:,2));
tha(tha<=0)=tha(tha<=0)+2*pi;
thb(thb<=0)=thb(thb<=0)+2*pi;
na = length(tha);
nb = length(thb);
n = 50; % Nbr of interpolated points
i = 1:n;
thetaa(i) = (tha(na)-tha(1))*(i-1)/(n-1) + tha(1);
thetab(i) = (thb(nb)-thb(1))*(i-1)/(n-1) + thb(1);
xa = interp1(tha,a(:,1),thetaa);
ya = interp1(tha,a(:,2),thetaa);
xb = interp1(thb,b(:,1),thetab);
yb = interp1(thb,b(:,2),thetab);
plot(xa,ya,'*:',xb,yb,'+:')
2 Commenti
Mathieu NOE
il 16 Ott 2025
I wonder if the OP wanted something like a spline interpolation, and with equidistant with ds = sqrt(dx²+dy²) in mind ?
Mohamad TOUT
il 16 Ott 2025
Categorie
Scopri di più su Interpolation in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

