Error using / Matrix dimensions must agree

10 ビュー (過去 30 日間)
Jose Miguel Araya Martinez
Jose Miguel Araya Martinez 2022 年 6 月 28 日
編集済み: Voss 2022 年 6 月 28 日
My script is this:
r=linspace(-180,180,360);
t=linspace(-180,180,360);
[R,T]=meshgrid(r,t);
phi_=6*r*cos(1+5^2/R.^2)-T;
contour(R,T,phi_)
but matlab throws the following error: Error using / Matrix dimensions must agree.
What am i doing wrong?

採用された回答

Voss
Voss 2022 年 6 月 28 日
Use ./
r=linspace(-180,180,360);
t=linspace(-180,180,360);
[R,T]=meshgrid(r,t);
% phi_=6*r*cos(1+5^2/R.^2)-T;
phi_=6*r*cos(1+5^2./R.^2)-T;
contour(R,T,phi_)
  2 件のコメント
Jose Miguel Araya Martinez
Jose Miguel Araya Martinez 2022 年 6 月 28 日
Thanks!
Voss
Voss 2022 年 6 月 28 日
編集済み: Voss 2022 年 6 月 28 日
You're welcome!
As @Star Strider points out, you probably intend to use .* as well, but using / instead of ./ is what caused the error.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by