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!