How can I create a 3d plot with each vector displayed as an arrow, and one line connecting the tail to tip?
11 views (last 30 days)
Show older comments
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 Comments
Answers (1)
Adam Hug
on 30 Jun 2015
It sounds like the "quiver3" function is what you are looking for. Check out this doc link for the details:
0 Comments
See Also
Categories
Find more on Logical 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!