reference line in plot

5 次查看(过去 30 天)
ali hassan
ali hassan 2020-12-19
hello everyone
hope u r fine
actually i am plotting a using implict command and i want to make my z axis as a prominant line as i hav done it here.
code:
clear
clc
close
%% Receivers coordinates
lats = [34.1989 34.0105 34.067894 34.1166 34.0151]; longs = [72.0231 71.9876 71.992783 72.0216 71.5249];
[x,y] = grn2eqa(lats,longs,[34.1166, 72.0216])
% x=[8 0 -8 0 ].*100; %%x=[x_1 x_2 x_3 x_p]
% x(5) = -x(5); y(5) = -y(5);
% y=[-4 8 -4 5].*100; %%y=[y_1 y_2 y_3 y_p]
z=[0 0 0 0]; %%z=[z_1 z_2 z_3 z_p]
c=2.997924580*10^8;
%% Source TDOA calculation
z_s=0.0098;
t1 = (sqrt((x(5)-x(4))^2+(y(5)-y(4))^2+(z_s-z(4))^2)-sqrt((x(5)-x(1))^2+(y(5)-y(1))^2+(z_s-z(1))^2))/c
t2 = (sqrt((x(5)-x(4))^2+(y(5)-y(4))^2+(z_s-z(4))^2)-sqrt((x(5)-x(2))^2+(y(5)-y(2))^2+(z_s-z(2))^2))/c
t3 = (sqrt((x(5)-x(4))^2+(y(5)-y(4))^2+(z_s-z(4))^2)-sqrt((x(5)-x(3))^2+(y(5)-y(3))^2+(z_s-z(3))^2))/c
%% Source localization
syms xs ys zs %our unknowns
eqn1 = sqrt((xs-x(4))^2+(ys-y(4))^2+(zs-z(4))^2)-sqrt((xs-x(1))^2+(ys-y(1))^2+(zs-z(1))^2)-(c*t1);
eqn2 = sqrt((xs-x(4))^2+(ys-y(4))^2+(zs-z(4))^2)-sqrt((xs-x(2))^2+(ys-y(2))^2+(zs-z(2))^2)-(c*t2);
eqn3 = sqrt((xs-x(4))^2+(ys-y(4))^2+(zs-z(4))^2)-sqrt((xs-x(3))^2+(ys-y(3))^2+(zs-z(3))^2)-(c*t3);
sol = solve([eqn1, eqn2, eqn3], [xs ys zs]);
figure(1)
% fimplicit3(eqn1,[-0.008 0.001 -0.002 0.0015 0 0.015],'EdgeColor','none','FaceAlpha',.5)
fimplicit3(eqn1,[-0.008 0.001 -0.002 0.0015 -0.015 0.015],'EdgeColor','b','FaceAlpha',0)
hold on
fimplicit3(eqn2,[-0.008 0.001 -0.002 0.0015 -0.015 0.015],'EdgeColor','g','FaceAlpha',0)
fimplicit3(eqn3,[-0.008 0.001 -0.002 0.0015 -0.015 0.015],'EdgeColor','y','FaceAlpha',0)
% fimplicit3(eqn2,[-0.008 0.001 -0.002 0.0015 -0.015 0.015],'EdgeColor','none','FaceAlpha',.5)
% fimplicit3(eqn3,[-0.008 0.001 -0.002 0.0015 -0.015 0.015],'EdgeColor','none','FaceAlpha',.5)
%%
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
%%
%%Filtering Results
%idx = all(possibleSol < 0) | all(imag(possibleSol) ~=0)
idx = possibleSol(3,:) < 0 | any(imag(possibleSol) ~=0)
possibleSol(:, idx) = [];
[lat,long] = eqa2grn(possibleSol(1),possibleSol(2),[34.1166, 72.0216])
%Plotting on 3D coordinates
% fprintf('Xs=%g\n', possibleSol(1,1)); quiver3
% fprintf('Ys=%g\n', possibleSol(2,1));
% fprintf('Zs=%g\n', possibleSol(3,1));
% scatter3(x, y, z, 'o');
% hold on
% scatter3(possibleSol(1,1), possibleSol(2,1), possibleSol(3,1), '+');
% hold off
% legend({'Receivers', 'Source'})
figure(2)
hold on
grid on
view(3);
plot3(x(1:4),y(1:4),z, 'ro', 'LineWidth', 2, 'MarkerSize', 10);
plot3(possibleSol(1),possibleSol(2),possibleSol(3), 'b+', 'LineWidth', 4, 'MarkerSize', 10)
plot3(x(5),y(5),z_s,'g+', 'LineWidth', 2, 'MarkerSize', 10)
legend({'Receivers', 'Source','exactvalue'})
  1 个评论
源樹 上林
源樹 上林 2020-12-22
zline ... is not available, how about this?
x = xlim;
y = ylim;
y = [y(2) y(2)];
z = [0 0];
hold on
plot3(x, y, z)
hold off

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Numerical Integration and Differential Equations 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by