Problem dividing matrix by vector
Show older comments
Hi
I have a matrix of 20301*20301 

and a vector of 20301*1
...(after 201 iterations, so at cell 202 the numbers start.Before it was all zeros)
...(after 201 iterations, so at cell 202 the numbers start.Before it was all zeros)
When I try dividing the using A\b, the error "Warning:Singular Matrix .." comes up and my answer is just NaNs. I compared my answer to a friend and while he got the exact values of A and b his division worked and he got actual values. I was wondering if anyone could shed light on this situation
16 Comments
the cyclist
on 28 Mar 2020
Can you upload your data (in a mat file) and the code you used (in either an m file, or by pasting the code)? Please don't paste an screenshot of the code, which would require us to retype it out to use it.
the cyclist
on 28 Mar 2020
Are you sure that your friend has identical inputs? It seems to me that between you and your friend, you must have at least one of the following, if you are getting different results:
- different inputs
- different calculation
- different versions of MATLAB
- different hardware
(or maybe some other difference I am forgetting).
Torsten
on 28 Mar 2020
Do you really want to solve A*x = b for x or do you only want to divide each row (column) of A by the vector b ?
Maaz Madha
on 28 Mar 2020
Edited: Maaz Madha
on 28 Mar 2020
Maaz Madha
on 28 Mar 2020
Torsten
on 28 Mar 2020
The code will neither produce a matrix A nor a vector b.
Maaz Madha
on 28 Mar 2020
Torsten
on 28 Mar 2020
an and as are matrices of two dimensions - you address them as arrays of one dimension.
T((i-1)*dx,(j-1)*dy) is usually undefined since (i-1)*dx and (j-1)*dy are not integers in general.
Maaz Madha
on 28 Mar 2020
Torsten
on 28 Mar 2020
Sorry, I did not see that T was not a matrix, but a function.
Maaz Madha
on 28 Mar 2020
Equations for T2 - T9 must be derived from the boundary conditions of your problem to get a nonsingular matrix A. I don't see where you incorporate boundary conditions.
Further, beginning with time step 2, T in the equations must be replaced by the Temp vector of the preceeding time step. Thus it will be better to work with Temp instead of T in the definition of b.
Maaz Madha
on 28 Mar 2020
Torsten
on 28 Mar 2020
Which boundary conditions did you try to incorporate at the four edges ?
T in your code is the initial temperature at time t=0. If you want to stick to T in your b vector, you will have to redefine your function for T since T becomes Temp.
Maaz Madha
on 28 Mar 2020
Edited: Maaz Madha
on 28 Mar 2020
Maaz Madha
on 28 Mar 2020
Answers (0)
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!