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

In summary, the conversation discussed a problem with modeling the convective transport of material through soil using MatLab. The equation used was d(Th*C) / d(t) = - q * d(C) / d(z), with parameters such as time, depth model, flow velocity, and initial concentrations defined. The solution was written in matrices, but encountered a warning due to a loss of diagonal dominance in the matrix. The solution suggested was to write a program using the Gauss Seidel method to solve the system instead of relying on MatLab functions.
  • #1
Huibert
6
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
  • #2
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.
 

What does the warning "Matrix is singular, close to singular or badly scaled" mean?

The warning means that your matrix is either not invertible, nearly not invertible, or has elements with very large or very small values. This can lead to inaccurate results or errors in your calculations.

Why is it important to address this warning?

Addressing this warning is important because it can affect the accuracy and reliability of your results. If your matrix is singular or badly scaled, your calculations may not be correct and could lead to incorrect conclusions.

How can I fix this warning?

To fix this warning, you can try scaling your matrix or using a different method for solving your problem. You can also check for any errors in your input data that may be causing the warning.

Can this warning be ignored?

It is not recommended to ignore this warning, as it can lead to inaccurate results. However, if you are certain that the warning is not affecting your calculations, you can suppress the warning by using the "warning off" command in MatLab.

Is there a way to prevent this warning from occurring?

You can prevent this warning from occurring by carefully selecting your input data and ensuring that your matrix is not close to being singular. You can also use more robust methods for solving your problem, such as using the "pinv" function instead of the inverse.

Similar threads

  • Calculus and Beyond Homework Help
Replies
2
Views
267
  • Engineering and Comp Sci Homework Help
Replies
1
Views
707
  • Calculus and Beyond Homework Help
Replies
1
Views
615
  • Engineering and Comp Sci Homework Help
Replies
15
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
18
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
10
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
1K
  • Calculus and Beyond Homework Help
Replies
3
Views
515
  • Engineering and Comp Sci Homework Help
Replies
2
Views
1K
Back
Top