How to create a quiver with given code?
1 回表示 (過去 30 日間)
古いコメントを表示
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.
0 件のコメント
採用された回答
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))
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Vector Fields についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!