How can I put arrow heads on the plotted lines?

조회 수: 15 (최근 30일)
Wiqas Ahmad
Wiqas Ahmad 2021년 4월 26일
답변: Walter Roberson 2021년 4월 26일
I want to put arrow heads on the blue lines u,v and w so that they represent as vectors.
clear all;
close all;
clc;
%%
x=linspace(0,2,50);
y=linspace(0,2,50);
z=linspace(0,2,50);
[X, Y, Z]=meshgrid(x,y,z);
Ex=sin(-2*pi*Z/2+pi);
Ey=0*X;
Ez=0*X;
[Bx, By, Bz]=curl(X, Y, Z, Ex, Ey, Ez);
for k=1:50
E(k)=mean(mean(Ex(:,:,k),1),2);
B(k)=mean(mean(Ex(:,:,k),1),2);
end
%%
hold on
plot3(0,0,0,'r','Linewidth',2);
quiver3(0*x(1:2:50),0*y(1:2:50),0*z(1:2:50),0*x(1:2:50),0*y(1:2:50),0*z(1:2:50),0,'b', 'Linewidth', 2);
hold on
plot3(x,0*y,0*z,'b','LineWidth',2);%%% plotting inner axis lines
plot3(0*x,-y,0*z,'b','LineWidth',2);
plot3(0*x,0*y,z,'b','LineWidth',2);
text(1.2,0,0,'v','FontSize', 14);%%% showing x,y,z at the axis end
text(0,-1.2,0,'w','FontSize', 14);
text(0,0,1.2,'u','FontSize', 14);
grid on
set(gca,'FontSize', 14, 'Linewidth',1);%%% controle size of the figure
xlabel('\bf x','position',[0 -1.45 -1])
ylabel('\bf y','position',[-1.45 0 -1])
zlabel('\bf z')
xlim([-1 1]);
ylim([-1 1]);
zlim([-1 1]);
Ax = gca;
Ax.XAxis.Visible = 'on';%%% turn OFF or ON the outer-axis of the box
Ax.YAxis.Visible = 'on';
Ax.ZAxis.Visible = 'on';
box off
view(3)
camup([-1 0 1]) %%%camera view can be change by changing values.
camroll(90)%%%can also rotate the camera

답변 (1개)

Walter Roberson
Walter Roberson 2021년 4월 26일
https://stackoverflow.com/questions/42623867/putting-arrows-in-a-matlab-figure-showing-orientation-of-axes

카테고리

Help CenterFile Exchange에서 Lighting, Transparency, and Shading에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by