help draw curved line between two points

18 views (last 30 days)
Hello everyone, I need to draw a curved line beetween two points, how can i do it?
For now I have tried this way but I get a straight line:
clear
close
clc
Pos = importdata("Pos07_12_21.txt");
x1 = [Pos(1,1);Pos(2,1);Pos(3,1)];
y1 = [Pos(1,2);Pos(2,2);Pos(3,2)];
z1 = [Pos(1,3);Pos(2,3);Pos(3,3)];
plot3(x1,y1,z1,"k");
p.s.: pos=
10009.6827000000 49968.6391000000 618.340200000000
10019.7800000000 49979.0046000000 622.162400000000
10027.3819000000 49987.1384000000 619.442100000000
10009.6970000000 49968.6459000000 618.464600000000
10019.7886000000 49978.9978000000 622.301900000000
10027.3794000000 49987.1322000000 619.574500000000
10016.3711000000 49962.0762000000 617.777700000000
10025.5792000000 49972.1036000000 622.192300000000
10034.0286000000 49980.8681000000 619.401100000000

Accepted Answer

Chunru
Chunru on 3 May 2023
Pos=[
10009.6827000000 49968.6391000000 618.340200000000
10019.7800000000 49979.0046000000 622.162400000000
10027.3819000000 49987.1384000000 619.442100000000
10009.6970000000 49968.6459000000 618.464600000000
10019.7886000000 49978.9978000000 622.301900000000
10027.3794000000 49987.1322000000 619.574500000000
10016.3711000000 49962.0762000000 617.777700000000
10025.5792000000 49972.1036000000 622.192300000000
10034.0286000000 49980.8681000000 619.401100000000];
x1 = [Pos(1,1);Pos(2,1);Pos(3,1)];
y1 = [Pos(1,2);Pos(2,2);Pos(3,2)];
z1 = [Pos(1,3);Pos(2,3);Pos(3,3)];
plot3(x1,y1,z1,"k");
hold on
% Interpolation to make it as smooth curve
xq = linspace(x1(1), x1(end), 51);
yz = interp1(x1, [y1 z1], xq, 'spline');
plot3(xq, yz(:, 1), yz(:,2), 'r')

More Answers (0)

Community Treasure Hunt

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

Start Hunting!