plotting 3D coordinates in 3D graph and label them

4 views (last 30 days)
ali hassan
ali hassan on 1 Oct 2020
Commented: ali hassan on 1 Oct 2020
HELLO EVERYONE
HOPE EVERYONE IS FINE AND GOOD.NEED SOME HELP
basically i gave 4 3D coordinates position in matlab and i got my transmitter location in coordinates.i want to plot them in matlab in 3d coordinates.
code:
x_p = 4; y_p = 5; z_p = 2;
x_1 = 8; y_1 = 9; z_1 = 5;
x_2 = 2; y_2 = 5; z_2 = 1;
x_3 = 6; y_3 = 1; z_3 = 3;
c=3.0*10^8;
t1 = 5.692820*10^-9;
t2 = -2.924173*10^-9;
t3 = -12.010097*10^-9;
syms xs ys zs %our unknowns
eqn1 = sqrt((xs-x_p)^2+(ys-y_p)^2+(zs-z_p)^2)-sqrt((xs-x_1)^2+(ys-y_1)^2+(zs-z_2)^2)-(c*t1);
eqn2 = sqrt((xs-x_p)^2+(ys-y_p)^2+(zs-z_p)^2)-sqrt((xs-x_2)^2+(ys-y_2)^2+(zs-z_2)^2)-(c*t2);
eqn3 = sqrt((xs-x_p)^2+(ys-y_p)^2+(zs-z_p)^2)-sqrt((xs-x_3)^2+(ys-y_3)^2+(zs-z_3)^2)-(c*t3);
sol = solve([eqn1, eqn2, eqn3], [xs ys zs]);
m = 1;
for n = 1:length(sol.xs)
possibleSol(1,m) = double(sol.xs(n));
possibleSol(2,m) = double(sol.ys(n));
possibleSol(3,m) = double(sol.zs(n));
m= m+1;
end
possibleSol(:, all(possibleSol>0 & imag(possibleSol)==0, 1))
output:
now i want to plot the reciever1(x1,y1,z1),receiver2(x2,y2,z2),receiver3(x3,y3,z3),receiver4(xp,yp,zp) and the coordinates i get in answer which is possibleSol(xs,ys,zs).receiver should be black and transmitter should be blue.and i also want to use legend to name the receiver.
BEST REGARDS

Answers (1)

Henry Ukwu
Henry Ukwu on 1 Oct 2020
scatter3 or plot3

Community Treasure Hunt

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

Start Hunting!