MATLAB: Warning: Rank deficient

rank deficient

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

Best Answer

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.