matrix multiplication error with too many variables in the equation .
1 view (last 30 days)
Show older comments
sanjay lakshminarayana
on 25 Aug 2019
Commented: Walter Roberson
on 26 Aug 2019
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 Comment
Accepted Answer
Bjorn Gustavsson
on 26 Aug 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
0 Comments
More Answers (0)
See Also
Categories
Find more on Array Geometries and Analysis in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!