フィルターのクリア

Quiver lines on contour not showing

2 ビュー (過去 30 日間)
Armando Marchena
Armando Marchena 2016 年 5 月 19 日
コメント済み: Star Strider 2016 年 5 月 21 日
Hi there, I have a contour plot which I successfully generated. However when I turn on the quiver lines, they do not show up on the plot. Below is my code:
[x,y] = meshgrid([1:0.1:6],[1:0.1:6]); %Creates axis.
f = 8.9875517873681764*10^9;
PC1 = 1e-6; %Charge of point one.
PC2 = 1e-6; %Charge of point two.
PC3 = 0.5e-6; %Charge of point three.
n = 20; %N-number of levels.
%Charge of individual points.
Charge1 = (f.*PC1)./sqrt((x-3).^2+(y-3).^2);
Charge2 = (f.*PC2)./sqrt((x-5).^2+(y-3).^2);
Charge3 = (f.*PC3)./sqrt((x-4).^2+(y-4).^2);
Sum = Charge1-Charge2+Charge3;
figure(1)
[px,py]=gradient(Sum);
contour(x,y,Sum,n)
hold on
quiver(x,y,px,py)
hold off
Does anyone have an idea why the quiver lines are not showing? Thanks.

採用された回答

Star Strider
Star Strider 2016 年 5 月 20 日
There seems to be a problem with the way you’re calculating the gradient. Making these changes will allow you to see the vectors and the contour plot (that I temporarily turned into contourf to make it visible). I will defer to you to determine what you need to do to fix it with the vector scaling turned back on:
[px,py]=gradient(Sum, 1E+4, 1E+4); % Set Derivative Intervals
figure(1)
contourf(x,y,Sum,n)
hold on
quiver(x,y,px,py,0) % Turn Off Scaling
hold off
  2 件のコメント
Armando Marchena
Armando Marchena 2016 年 5 月 21 日
Thanks you very much.
Star Strider
Star Strider 2016 年 5 月 21 日
My pleasure.

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

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by