How can I plot a unit vector in 3-D space?
이전 댓글 표시
Hello everyone,
I need help in plotting a 3-D unit vector. I was trying to use the "quiver3" command but could n't succeed. Any help or useful suggestions in this regard would be highly appreciated.
The details are:
I have a vector “r” with three components “x”, “y” and “z”. By definition, the unit vector of any vector is that vector divided by its magnitude. What I need to obtain is the corresponding unit vector in 3-D space in terms of arrows spread over x, y, and z coordinates.
Thanks.
clear all
close all
clc
N=101;
x=linspace(-10,10,N);
y=x;
z=y;
for i=1:length(x)
for j=1:length(y)
for k=1:length(z)
r_vec(i,j,k)=x(i)+y(j)+z(k);
r_mag(i,j,k)=sqrt(x(i).^2+y(j).^2+z(k).^2);
r_unit(i,j,k)=r_vec(i,j,k)./r_mag(i,j,k);
end
end
end
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Aerospace Blockset에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!