フィルターのクリア

Error using quiver The size of Y must match the size of U or the number of rows of U.

5 ビュー (過去 30 日間)
i am trying to create a vector field with app designer with the function quiver but i have an error 'Error using quiver
The size of Y must match the size of U or the number of rows of U.'
a = app.a.Value;
b = app.b.Value;
x1=0;
x2=2;
y1=0;
y2=2;
N = 20;
x = linspace(x1,x2,N);
y = linspace(y1,y2,N);
[X,Y]= meshgrid(x,y);
m = a.*y/b.*x;
S = atan (m);
U = cos (S);
V = sin (S);
quiver (app.Axes, X,Y,U,V);

採用された回答

KALYAN ACHARJYA
KALYAN ACHARJYA 2021 年 2 月 21 日
編集済み: KALYAN ACHARJYA 2021 年 2 月 21 日
Refer the MATLAB Docs, where U and V must be 2D as same sizes of X and Y. Please add the following line, this may allow to avoid the error
[U,V]=meshgrid(U,V);
  2 件のコメント
KALYAN ACHARJYA
KALYAN ACHARJYA 2021 年 2 月 21 日
編集済み: KALYAN ACHARJYA 2021 年 2 月 21 日
I have tried with non App case (Assigning the value a and b directly)
a = 2;
b= 3;
x1=0;
x2=2;
y1=0;
y2=2;
N = 20;
x = linspace(x1,x2,N);
y = linspace(y1,y2,N);
[X,Y]= meshgrid(x,y);
m = a.*y/b.*x;
S = atan (m);
U = cos (S);
V = sin (S);
[U,V]=meshgrid(U,V);
quiver (X,Y,U,V);
Alvaro Mª Zumalacarregui Delgado
Alvaro Mª Zumalacarregui Delgado 2021 年 2 月 21 日
Thank you very much!! i get it

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

その他の回答 (1 件)

Alvaro Mª Zumalacarregui Delgado
Alvaro Mª Zumalacarregui Delgado 2021 年 2 月 21 日
I have the same error but with other code, I only change the "m" value and Matlab sends me the same error:
P = 50;
Q = 60;
a = app.a.Value;
b = app.b.Value;
x1=0;
x2=2;
y1=0;
y2=2;
N = 20;
x = linspace(x1,x2,N);
y = linspace(y1,y2,N);
[X,Y]= meshgrid(x,y);
m = (P-a*y)/(Q-b*x);
S = atan (m);
U = -cos (S);
V = -sin (S);
[U,V]=meshgrid(U,V);
quiver (app.Axes, X,Y,U,V);
  2 件のコメント
KALYAN ACHARJYA
KALYAN ACHARJYA 2021 年 2 月 21 日
m = (P-a*y)./(Q-b*x);
%..........^
Alvaro Mª Zumalacarregui Delgado
Alvaro Mª Zumalacarregui Delgado 2021 年 2 月 21 日
Thank you so much! you can't imagine how you help me with that!

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

カテゴリ

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