Interpolate points between two coordinates
61 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Ahmed Abdulla
am 16 Aug. 2022
Beantwortet: Kevin Holly
am 16 Aug. 2022
I have the coordinates of points A and B, and I would like to obtain the coordinates of N number of points between A ans B if connected by a straight line
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1099770/image.jpeg)
0 Kommentare
Akzeptierte Antwort
Kevin Holly
am 16 Aug. 2022
Since you are doing linear interpolation, you can just use the linspace function.
A = [1,7];
B = [6,1];
N = 5; % You can change this number for number of points
x = [A(1) B(1)];
y = [A(2) B(2)];
scatter(x,y,'filled')
hold on
New_x = linspace(x(1),x(2),N+2); % Includes given points
New_y = linspace(y(1),y(2),N+2); % Includes given points
New_x(end)=[];
New_x(1)=[];
New_y(end)=[];
New_y(1)=[];
scatter(New_x,New_y,'r','filled')
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Interpolation finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!