How to create a quiver with given code?

3 vues (au cours des 30 derniers jours)
Jacob Allen
Jacob Allen le 2 Sep 2022
Commenté : Jacob Allen le 3 Sep 2022
Below is the current code I have so far.
clear all
clc
x=0:5:20;
y=0:10:40;
z=0:20:80;
[X,Y,Z]=meshgrid(x,y,z);
v=[];
for i=1:5
for j=1:5
for k=1:5
v(i,j,k,1)=X(i,j,k)^2+Y(i,j,k)^2+Z(i,j,k)^2;
v(i,j,k,2)=2*X(i,j,k)*Y(i,j,k)*Z(i,j,k);
v(i,j,k,3)=X(i,j,k)+Y(i,j,k)+2*Z(i,j,k);
end
end
end
disp('v is');
disp(v)
From this I need to create a figure presenting the vector field (quiver3
function), name all axes, change the fonts of all labels to 12, reverse the direction of Z-axis
and add the title. Finally, calculate the divergence (divergence function) and curl (curl
function) of the vector field v.
I have never used the quiver comment or the divergence and curl functions. Any help would be appriciated.

Réponse acceptée

Walter Roberson
Walter Roberson le 2 Sep 2022
x=0:5:20;
y=0:10:40;
z=0:20:80;
[X,Y,Z]=meshgrid(x,y,z);
v=[];
for i=1:5
for j=1:5
for k=1:5
v(i,j,k,1)=X(i,j,k)^2+Y(i,j,k)^2+Z(i,j,k)^2;
v(i,j,k,2)=2*X(i,j,k)*Y(i,j,k)*Z(i,j,k);
v(i,j,k,3)=X(i,j,k)+Y(i,j,k)+2*Z(i,j,k);
end
end
end
quiver3(X, Y, Z, v(:,:,:,1), v(:,:,:,2), v(:,:,:,3))
  1 commentaire
Jacob Allen
Jacob Allen le 3 Sep 2022
Awesome thank you so much.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Vector Fields dans Help Center et File Exchange

Produits


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by