How can I put arrow heads on the plotted lines?
8 views (last 30 days)
Show older comments
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
0 Comments
Answers (1)
Walter Roberson
on 26 Apr 2021
https://stackoverflow.com/questions/42623867/putting-arrows-in-a-matlab-figure-showing-orientation-of-axes
0 Comments
See Also
Categories
Find more on Camera Views in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!