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

  • Thread starter Thread starter Huibert
  • Start date Start date
  • Tags Tags
    Matlab Matrix
Click For Summary
SUMMARY

The forum discussion addresses a common issue encountered in MATLAB when modeling convective transport of materials through soil, specifically the warning "Matrix is singular, close to singular or badly scaled." This warning arises due to the loss of diagonal dominance in the coefficient matrix, often caused by having too many zero elements on the diagonal. To resolve this issue, users are advised to implement a custom solution using the Gauss-Seidel method instead of relying on MATLAB's built-in functions.

PREREQUISITES
  • Understanding of MATLAB programming and syntax
  • Familiarity with numerical methods, particularly matrix operations
  • Knowledge of the Gauss-Seidel method for solving linear equations
  • Basic concepts of convective transport modeling in soil
NEXT STEPS
  • Implement the Gauss-Seidel method in MATLAB for solving linear systems
  • Research techniques to ensure diagonal dominance in matrices
  • Explore MATLAB's matrix manipulation functions for better handling of singular matrices
  • Study numerical stability and scaling in matrix computations
USEFUL FOR

This discussion is beneficial for MATLAB users, particularly those involved in environmental modeling, numerical analysis, and anyone facing challenges with matrix computations in their programming projects.

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.
 

Similar threads

Replies
15
Views
3K
Replies
2
Views
2K
  • · Replies 18 ·
Replies
18
Views
2K
  • · Replies 10 ·
Replies
10
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 11 ·
Replies
11
Views
10K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 8 ·
Replies
8
Views
2K