How can I plot a unit vector in 3-D space?
Afficher commentaires plus anciens
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
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Programming dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!