Effacer les filtres
Effacer les filtres

matrix multiplication error with too many variables in the equation .

1 vue (au cours des 30 derniers jours)
ds = C*rho^(1/6)*m_v.*0.352*Vm2^0.857;
In the above equation , m_v = 1e-3:1:1000;
however I d like to run the same equation with rho = 3.4:1:100; C = 0.2:0.1:0.9; and so on . However I am unable to do so and i get an error which says matrix dimensions dont match or first matrix dimension and second matrix dimensions dont match.
I have tried .* and .^ but the error persists. Please help me out . Thank you in advance.
  1 commentaire
Walter Roberson
Walter Roberson le 26 Août 2019
If you want all the combinations, have a look at ndgrid()

Connectez-vous pour commenter.

Réponse acceptée

Bjorn Gustavsson
Bjorn Gustavsson le 26 Août 2019
Your first multiply are a matrix multiplication, you can achieve what you want if you
make sure that C is a column-vector and the second factor is a row-vector (rho.^(1/6)):
C = [1;2;3];
rho = [1 3 5 7 13];
ds = C*rho.^(1/6);
If your Vm2 is a matrix with some additional sizes you might have to loop a bit more.
Then you simply might be best off by looping over the values of m_v. If C and rho doesn't change calculate that product outside of the loop.
HTH

Plus de réponses (0)

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by