フィルターのクリア

I can't draw the vector field

2 ビュー (過去 30 日間)
윤형
윤형 2023 年 6 月 4 日
回答済み: the cyclist 2023 年 6 月 4 日
[x, y] = meshgrid(-0.9:0.3:0.9, -0.9:0.3:0.9);
R1 = (x.^2 + y.^2).^.5;
V = 1./R1;
figure(1)
surf(x, y, V)
view(-37.5, 20)
figure(2)
contour(x, y, V, 5)
hold on
axis square
[u, v] = gradient(V, 0.2);
quiver(x, y, -u, -v, 1.5)
axis equal
I can't draw the vector field. What's the problem

回答 (2 件)

Simon Chan
Simon Chan 2023 年 6 月 4 日
The spacing used in function gradient is 0.2, but the spacing in your data is 0.3 and hence it give you an error. Try using same spacing.

the cyclist
the cyclist 2023 年 6 月 4 日
The problem is the Inf values in u and v. Removing them:
[x, y] = meshgrid(-0.9:0.3:0.9, -0.9:0.3:0.9);
R1 = (x.^2 + y.^2).^.5;
V = 1./R1;
figure(1)
surf(x, y, V)
view(-37.5, 20)
figure
contour(x, y, V, 5)
hold on
axis square
[u, v] = gradient(V, 0.2);
u(isinf(u)) = NaN;
v(isinf(v)) = NaN;
quiver(x, y, -u, -v,1.5)
axis equal

カテゴリ

Help Center および File ExchangeApp Building についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by