matrix multiplication error with too many variables in the equation .

3 次查看(过去 30 天)
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.

采纳的回答

Bjorn Gustavsson
Bjorn Gustavsson 2019-8-26
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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Array Geometries and Analysis 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by