Problem dividing matrix by vector
显示 更早的评论
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 个评论
the cyclist
2020-3-28
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
2020-3-28
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
2020-3-28
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
2020-3-28
编辑:Maaz Madha
2020-3-28
Maaz Madha
2020-3-28
Torsten
2020-3-28
The code will neither produce a matrix A nor a vector b.
Maaz Madha
2020-3-28
Torsten
2020-3-28
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
2020-3-28
Torsten
2020-3-28
Sorry, I did not see that T was not a matrix, but a function.
Maaz Madha
2020-3-28
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
2020-3-28
Torsten
2020-3-28
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
2020-3-28
编辑:Maaz Madha
2020-3-28
Maaz Madha
2020-3-28
回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!