plotting vector in matlab

23 次查看(过去 30 天)
fima v
fima v 2024-11-8,15:15
回答: Pavl M. 2024-11-8,16:08
Hello,I have the following code to represent vectoric components of E-field.
The field has X and Y directions, as you can see in the photo I got a plot of two of the components.
Is there a way to plot the vectorial sum of the green and purple arrow vector.
Thanks.
clc
clear
x = linspace(0,4*pi,100);
figure;
%only line
plot3(x,zeros(1,100),zeros(1,100),'k','LineWidth',2);
hold on
plot3(x,sin(x),zeros(1,100),'k');
plot3(x,zeros(1,100),sin(x),'k');
xlabel('X axes', 'FontSize',10, 'FontName','NewsGotT', 'fontWeight','bold');
ylabel('Y axes', 'FontSize',10, 'FontName','NewsGotT', 'fontWeight','bold');
zlabel('Z axes', 'FontSize',10,'FontName','NewsGotT', 'fontWeight','bold');
x_quiver = 0:pi/4:4*pi;
q1 = quiver3(x_quiver,zeros(1,17),zeros(1,17),zeros(1,17),sin(x_quiver),zeros(1,17),0);
q2 = quiver3(x_quiver,zeros(1,17),zeros(1,17),zeros(1,17),zeros(1,17),sin(x_quiver),0);
hold off;

采纳的回答

Pavl M.
Pavl M. 2024-11-8,16:08
clc
clear
x = linspace(0,4*pi,100);
figure;
%only line
plot3(x,zeros(1,100),zeros(1,100),'k','LineWidth',2);
hold on
plot3(x,sin(x),zeros(1,100),'k');
plot3(x,zeros(1,100),sin(x),'k');
plot3(x,sin(x),sin(x),'k');
xlabel('X axes', 'FontSize',10, 'FontName','NewsGotT', 'fontWeight','bold');
ylabel('Y axes', 'FontSize',10, 'FontName','NewsGotT', 'fontWeight','bold');
zlabel('Z axes', 'FontSize',10,'FontName','NewsGotT', 'fontWeight','bold');
x_quiver = 0:pi/4:4*pi;
q1 = quiver3(x_quiver,zeros(1,17),zeros(1,17),zeros(1,17),sin(x_quiver),zeros(1,17),0);
q2 = quiver3(x_quiver,zeros(1,17),zeros(1,17),zeros(1,17),zeros(1,17),sin(x_quiver),0);
q3 = quiver3(x_quiver,zeros(1,17),zeros(1,17),zeros(1,17),sin(x_quiver),sin(x_quiver),0);
hold off;

更多回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by