Borrar filtros
Borrar filtros

How can I create a 3d plot with each vector displayed as an arrow, and one line connecting the tail to tip?

16 visualizaciones (últimos 30 días)
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.

Respuestas (1)

Adam Hug
Adam Hug el 30 de Jun. de 2015
It sounds like the "quiver3" function is what you are looking for. Check out this doc link for the details:

Categorías

Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by