필터 지우기
필터 지우기

Plotting zero vectors in quiver3

조회 수: 1 (최근 30일)
David Meixell
David Meixell 2020년 12월 3일
댓글: KSSV 2020년 12월 3일
I'm trying to plot the curl of the function v = -y + x + 0. This comes to (0,0,2), but I get an error stating the variables must be the same size, so I suspect the zeros are causing issues. How can I do a quiver3 plot with these numbers?
%% set up mesh
Xvc=(-5:2:5)';
Yvc=(-5:2:5)';
Zvc=(-5:2:5)';
[X,Y,Z]=meshgrid(Xvc, Yvc, Zvc);
%% plot V
Vx=-Y; % Ex 2 Vx from worksheet
Vy=X; % Ex 2 Vy from worksheet
Vz=0; % Ex 2 Vz from worksheet
figure(110)
quiver3(X, Y, Z, Vx, Vy, Vz); %Changed to 2D plot due to lack of Vz values
grid on
xlabel('Vx')
ylabel('Vy')
%% compute curl
Crlx=0; %Curl X from solved worksheet
Crly=0; %Curl Y from solved worksheet
Crlz=2; %Curl Z from solved worksheet
figure(120)
quiver(X, Y, Z, Crlx, Crly, Crlz);
grid on
tmp=0;

채택된 답변

KSSV
KSSV 2020년 12월 3일
편집: KSSV 2020년 12월 3일
%% set up mesh
Xvc=(-5:2:5)';
Yvc=(-5:2:5)';
Zvc=(-5:2:5)';
[X,Y,Z]=meshgrid(Xvc, Yvc, Zvc);
%% plot V
Vx=-Y; % Ex 2 Vx from worksheet
Vy=X; % Ex 2 Vy from worksheet
Vz=zeros(size(X)); % Ex 2 Vz from worksheet
figure
quiver3(X, Y, Z, Vx, Vy, Vz); %Changed to 2D plot due to lack of Vz values
view(3)
grid on
xlabel('Vx')
ylabel('Vy')
  댓글 수: 2
David Meixell
David Meixell 2020년 12월 3일
Ah! So for the second part, if I change it to the following, it should work as well?
%% compute curl
Crlx=zeros(size(X)); %Curl X from solved worksheet = 0
Crly=zeros(size(X)); %Curl Y from solved worksheet = 0
Crlz=2*ones(size(X)); %Curl Z from solved worksheet = 2
KSSV
KSSV 2020년 12월 3일
Yes it will work.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Vector Fields에 대해 자세히 알아보기

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by