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!