How can I create a 3d plot with each vector displayed as an arrow, and one line connecting the tail to tip?
13 次查看(过去 30 天)
显示 更早的评论
I am trying to create a program that can import an excel file of 3 columns with the vector data, and display these vectors into a 3d graph. Here's my code so far. I am only getting an empty graph generated though :/
data = xlsread('vectordata.xlsx');
radius = data(:,1);
theta = data(:,2);
phi = data(:,3);
x = radius.*cos(theta).*sin(phi);
y = radius.*sin(theta).*sin(phi);
z = radius.*cos(phi);
sumx = sum(x(:));
sumy = sum(y(:));
sumz = sum(z(:));
[radius, theta, phi] = cart2sph(sumx, sumy, sumz);
xpt(1) = 0;
ypt(1) = 0;
zpt(1) = 0;
pt(1,1) = xpt;
pt(1,2) = ypt;
pt(1,3) = zpt;
numvec = size(data,1);
for k = 1:numvec;
xpt1 = 1:numvec;
ypt1 = 1:numvec;
zpt1 = 1:numvec;
end
figure
plot3(radius, theta, phi);
axis([0 5 0 5 0 5]);
xlabel('x forces');
ylabel('y forces');
zlabel('z forces');
title('3D vector graph');
thanks in advance.
0 个评论
回答(1 个)
Adam Hug
2015-6-30
It sounds like the "quiver3" function is what you are looking for. Check out this doc link for the details:
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!