Adding a line to my plot3 of a plane
32 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I am having a bit of a problem adding a line to my plot3 of a plane. This is my code for plotting just the plane
X = Final(1,:,:);
Y = Final(2,:,:);
Z = Final(3,:,:);
plot3(X,Y,Z,'o','color','b');
and it gives me this plot, which is what I want :
But then I wanted to add position vector to it - and as I understood it then its just a line from point b to projection of b onto the new plane (which is what is in the plot above).
So I just chose one of the original points as the p1 and p2 as the projection of it and then wanted to plot a line between them and add to the plot above. There I am having the trouble.
%Position vector
p1 = [200; -107; 0] %%original point
p2 = [201 ; -105; 3] %projected point
X = Final(1,:,:);
Y = Final(2,:,:);
Z = Final(3,:,:);
hold on
plot(p1,p2) %line plot
plot3(X,Y,Z,'o','color','b');
grid;
hold off
This is the result, but I was hoping for something like this:
0 Commenti
Risposte (1)
Asad (Mehrzad) Khoddam
il 21 Ott 2020
Two lines should be fixed:
1- coordinates of end points of the line
2- Using plot3
%Position vector
p1 = [200; -107; 0] %%original point
p2 = [201 ; -105; 3] %projected point
px=[100 , 101];
py=[-107, -105];
pz=[0,3];
X = Final(1,:,:);
Y = Final(2,:,:);
Z = Final(3,:,:);
hold on
plot3(px,py,pz) %line plot
plot3(X,Y,Z,'o','color','b');
grid;
hold off
0 Commenti
Vedere anche
Categorie
Scopri di più su 2-D and 3-D Plots in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!