How to create a quiver with given code?

3 Ansichten (letzte 30 Tage)
Jacob Allen
Jacob Allen am 2 Sep. 2022
Kommentiert: Jacob Allen am 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.

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 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))

Weitere Antworten (0)

Kategorien

Mehr zu Vector Fields finden Sie in Help Center und File Exchange

Produkte


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by