I am calculating loss factors in pipe segmants, this is my code so far.
g = 9.81;
L = [250 100 125 125 100; %Length of pipe segmants
125 100 125 100 0;
125 100 125 100 0];
D = [0.3 0.2 0.2 0.2 0.2; %Diamters of pipe segmants
0.2 0.15 0.25 0.15 0;
0.2 0.15 0.25 0.15 0];
K = 8*L(:,:)/((pi^2)*g*(D(:,:).^5))
When I run the code this is what i get
Warning: Rank deficient, rank = 2, tol = 2.701149e-16.
> In PIPe (line 14)
K =
1.0e+03 *
8.3883 8.0146 0
3.5431 9.9398 0
3.5431 9.9398 0
When I calculate the denominator and numerator of K separately i get the correct matrix size but not when i run the whole equation

 採用された回答

John D'Errico
John D'Errico 2019 年 3 月 8 日

2 投票

I assume you really wanted to just divide each element of the second matrix into the first. Use the ./ operator for that. The slash operator has a very specific meaning in MATLAB, one that you are surely not expecting.
help slash
Thus, you need to do this:
K = 8*L(:,:)./((pi^2)*g*(D(:,:).^5))
for effectively the same reason you used .^ in that expression.

1 件のコメント

carlo frode
carlo frode 2019 年 3 月 8 日
Awesome! Thank you

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange で Foundation and Custom Domains についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by