I want to get a scaled vector field $\vec F=(x^2-x)i+(y^2-y)j$. The Fig should be like the attached Fig:

4 ビュー (過去 30 日間)
I want to get a scaled vector field $\vec F=(x^2-x)i+(y^2-y)j$. The Fig should be like the attached Fig:
[x,y] = meshgrid(-2:.16:2,-2:.16:2);
Fx = (x.*x-x);
Fy=y.*y-y;
figure;
quiver(x,y,Fx,Fy,'k','linewidth',1.2)
hold on
x=-2:0.01:2;
y=1-x;
plot(x,y,'k','linewidth',2);
Note that we have $div \vec F>0$ for $x+y>1$, $div \vec F<0$ for $x+y<1$ and $div \vec F=0$ on the line $x+y=1$ .
  3 件のコメント
Atom
Atom 2023 年 12 月 25 日
@John D'Errico Sorry, I have edited. Still I am not getting the desire plot.
Dyuman Joshi
Dyuman Joshi 2023 年 12 月 25 日
What is the vector field scaled to?
The arrows of the vector field in the reference image appear to be of the same length.

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

採用された回答

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2023 年 12 月 25 日
Is this what you are trying to obtain:
[x, y] = meshgrid(-2:0.25:2); % x and y values
F_x = 1*(x.^2 - x); % The vector field of x
F_y = 1*(y.^2 - y); % The vector field of y
F = F_x+F_y;
% Normalize the vectors
magnitude = sqrt(F_x.^2 + F_y.^2);
F_x_Nor = F_x ./ magnitude;
F_y_Nor = F_y ./ magnitude;
% Plot the scaled vector field
quiver(x, y, F_x_Nor, F_y_Nor);
hold on
X=-2:0.1:2;
Y=1-X;
plot(X,Y,'k','linewidth',2);
xlabel('x');
ylabel('y');
title('Scaled Vector Field: F = (x^2 - x) + (y^2 - y)');
axis([-2 2 -2 2])

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by