Problem with plotting vector fields

1 回表示 (過去 30 日間)
Randy Chen
Randy Chen 2020 年 10 月 13 日
コメント済み: Randy Chen 2020 年 10 月 14 日
I keep getting this error while trying to plot a vector field:
[X,Y] = meshgrid(2:10,2:10);
U = X/(X^2+Y^2);
V = Y/(X^2+Y^2);
quiver(X,Y,U,V,0)
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
I don't understand. What does this mean??
  1 件のコメント
Randy Chen
Randy Chen 2020 年 10 月 13 日
also the figure I get comes out to be emtpy

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

採用された回答

Stephen23
Stephen23 2020 年 10 月 13 日
編集済み: Stephen23 2020 年 10 月 13 日
"also the figure I get comes out to be emtpy"
You need to use array operations, not matrix operations:
>> [X,Y] = meshgrid(2:10,2:10);
>> U = X./(X.^2+Y.^2); % note array operations ./ and .^
>> V = Y./(X.^2+Y.^2); % note array operations ./ and .^
>> quiver(X,Y,U,V,0)
Tip: if you are not doing linear algebra then most likely you should be using array operations:
"I don't understand. What does this mean??"
The matrix operation mrdivide you used by mistake is trying to solve an unsolvable set of equations. The fact that it solves sets of equations is explained in its documentation, which is why you should read the documentation for every operator that you use, no matter how trivial you think it is.
  3 件のコメント
Stephen23
Stephen23 2020 年 10 月 13 日
@Randy Chen : please remember to accept my answer!
Randy Chen
Randy Chen 2020 年 10 月 14 日
just did!

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

その他の回答 (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