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 CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by