Help with "Error using / Matrix dimensions must agree."

1 回表示 (過去 30 日間)
Dan Giffin
Dan Giffin 2023 年 6 月 14 日
コメント済み: Star Strider 2023 年 6 月 14 日
Hi,
So my code looks like:
---------------------------------------------------
Air_desnity=[0.646:0.01:1.225];
W_412_MTOW=5534;
A_412=153.93804;
Power_412=(W_412_MTOW*9.81)^3/(2*Air_desnity*A_412).^0.5
--------------------------------------------------------------
And the error is:
Error using /
Matrix dimensions must agree.
Error in Power (line 6)
Power_412=(W_412_MTOW*9.81)^3/(2*Air_desnity*A_412).^0.5
------------------------------------------------------------------------------------------------
Could someone explain what the error means I tried following it and applying the steps but it doesn't make any sense to me

採用された回答

Star Strider
Star Strider 2023 年 6 月 14 日
Use element-wise division, so (./) instead of (/) —
Air_desnity=[0.646:0.01:1.225];
W_412_MTOW=5534;
A_412=153.93804;
Power_412=(W_412_MTOW*9.81)^3./(2*Air_desnity*A_412).^0.5
Power_412 = 1×58
1.0e+13 * 1.1345 1.1259 1.1174 1.1091 1.1010 1.0930 1.0853 1.0777 1.0702 1.0629 1.0558 1.0488 1.0419 1.0352 1.0285 1.0221 1.0157 1.0095 1.0033 0.9973 0.9914 0.9856 0.9799 0.9743 0.9688 0.9633 0.9580 0.9528 0.9476 0.9425
.
  2 件のコメント
Dan Giffin
Dan Giffin 2023 年 6 月 14 日
Seems to work. Much appreciated!
Star Strider
Star Strider 2023 年 6 月 14 日
As always, my pleasure!

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

その他の回答 (1 件)

Satwik
Satwik 2023 年 6 月 14 日
In order to perform elementwise division you should use ./ instead of /
Air_desnity=[0.646:0.01:1.225]
Air_desnity = 1×58
0.6460 0.6560 0.6660 0.6760 0.6860 0.6960 0.7060 0.7160 0.7260 0.7360 0.7460 0.7560 0.7660 0.7760 0.7860 0.7960 0.8060 0.8160 0.8260 0.8360 0.8460 0.8560 0.8660 0.8760 0.8860 0.8960 0.9060 0.9160 0.9260 0.9360
W_412_MTOW=5534;
A_412=153.93804;
Power_412=(W_412_MTOW*9.81)^3./(2*Air_desnity*A_412).^0.5
Power_412 = 1×58
1.0e+13 * 1.1345 1.1259 1.1174 1.1091 1.1010 1.0930 1.0853 1.0777 1.0702 1.0629 1.0558 1.0488 1.0419 1.0352 1.0285 1.0221 1.0157 1.0095 1.0033 0.9973 0.9914 0.9856 0.9799 0.9743 0.9688 0.9633 0.9580 0.9528 0.9476 0.9425

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by