How to create a quiver with given code?

3 ビュー (過去 30 日間)
Jacob Allen
Jacob Allen 2022 年 9 月 2 日
コメント済み: Jacob Allen 2022 年 9 月 3 日
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.

採用された回答

Walter Roberson
Walter Roberson 2022 年 9 月 2 日
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 件のコメント
Jacob Allen
Jacob Allen 2022 年 9 月 3 日
Awesome thank you so much.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeVector Fields についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by