Borrar filtros
Borrar filtros

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

2 visualizaciones (últimos 30 días)
Dan Giffin
Dan Giffin el 14 de Jun. de 2023
Comentada: Star Strider el 14 de Jun. de 2023
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

Respuesta aceptada

Star Strider
Star Strider el 14 de Jun. de 2023
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 comentarios
Dan Giffin
Dan Giffin el 14 de Jun. de 2023
Seems to work. Much appreciated!
Star Strider
Star Strider el 14 de Jun. de 2023
As always, my pleasure!

Iniciar sesión para comentar.

Más respuestas (1)

Satwik
Satwik el 14 de Jun. de 2023
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

Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by