MatLab Warning: Matrix is singular, close to singular or badly scaled

  • Thread starter Thread starter Huibert
  • Start date Start date
  • Tags Tags
    Matlab Matrix
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
1 reply · 19K views
Huibert
Messages
5
Reaction score
0
1. I try to model (MatLab) the convective transport of material trough the soil


2. The equation I use is: d(Th*C) / d(t) = - q * d(C) / d(z).
Th = soil moisture content,
C = concentration,
t = time,
q = flow velocity of groundwater,
z = depth.

Parameters
time = 20 h
dt = 0.2 h
depth model = 50 cm
dz = 0.05 cm
flow velocity = 0.1 cm/h
soil moisture content = 0.4 cm/cm
initial C = 0 g/cm
C at z_0 = 5 g/cm
C at z_end = 0 g/cm

I wrote the numerical solution in matrices:

(Th+ML) * C(i+1) = (Th+MR)*C(i)+BC

C(i+1) is a vector with the concentrations of 'n' depths at t = i+1. C(i): idem at t = i. BC is a vector that determines the boundary conditions (at j = top of model and j = bottom of model). Th is a matrix with Moisture Content values at the 0th diagonal.


3. So after defining the matrices, i modeled
Code:
        for i = 1:Nt-1
            Csim(:,i+1) = inv(Th+ML)*((Th+MR)*Csim(:,i)+BC);
        end

Result: Warning: Matrix is singular, close to singular or badly scaled.
Results may be inaccurate. RCOND = NaN.

What can be the problem and how could it possibly be solved? The MatLab help didn't really explain it to me (note: this is my first programming experience).
Thanks in advance!
 
Physics news on Phys.org
huibert, this is a common problem with matrix calculations. it is arising due to loss of diagonal dominance of matrix . i.e. the matrix may contain more number of zero as diagonal elements.this results in the situation that determinant of ur coefficient matrix become zero. only way to overcome this is by writing a program for solving the system by yourself rather than using MATLAB functions. use gauss seidel method.