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

  • Thread starter Thread starter Huibert
  • Start date Start date
  • Tags Tags
    Matlab Matrix
AI Thread Summary
The discussion centers on a MATLAB user encountering a "Matrix is singular, close to singular or badly scaled" warning while modeling convective transport of material through soil. The user defined a numerical solution using matrices but received an error indicating potential inaccuracies due to the matrix's loss of diagonal dominance, often caused by zero diagonal elements. To resolve this issue, it is suggested that the user implement a custom solution method, such as the Gauss-Seidel method, instead of relying on MATLAB's built-in functions. This approach may help avoid the singularity problem and yield more accurate results. The discussion highlights common challenges faced in numerical matrix calculations in MATLAB.
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.
 
Back
Top