Code of Iterative method's test
이전 댓글 표시
I wrote a code to solve a linear system using Successive Relaxation Iterative method
but I don't know how to add the test and write its code
can anyone help me
댓글 수: 4
Image Analyst
2014년 7월 12일
How can you know enough to write the code for "Successive Relaxation Iterative method" but not know enough to write code to call the function with some input variables? Calling the function should be the easier of the 2 m-files to write. If you can wrote the function, you can write a 2 line program to call the function.
Fatima Al Marzoqi
2014년 7월 12일
Matt J
2014년 7월 12일
When you call the function with some sample input, do you get the output you expect? If so, what more is there to do?
답변 (2개)
Roger Stafford
2014년 7월 12일
It looks as though you might be testing to see if the square matrix, R, fails to be "diagonally dominant". If so, here is a method:
Ra = abs(R);
if any(sum(Ra,2)>2*diag(Ra))
display ('Test Failed')
end
댓글 수: 4
Fatima Al Marzoqi
2014년 7월 12일
Roger Stafford
2014년 7월 12일
Your comment puzzles me greatly, Fatima! To show that R is not diagonally dominant is to show that in at least one row of R the absolute value of the diagonal element is less than the sum of the remaining row elements. That is what my code does and I am guessing that is what you intended your code to do (though it does not succeed in this.) My guess of diagonal dominance was based both on your statement " for each row the on diagonal element must be greater than the rest elements " and on your code attempt. If you are trying to test for some other property, please tell us what that is.
Fatima Al Marzoqi
2014년 7월 12일
Roger Stafford
2014년 7월 12일
I don't see anything like my code in your 'proj.m' code. Where are you doing a test remotely resembling "any(sum(Ra,2)>2*diag(Ra))"? Nowhere do you have an 'any' command nor do you ever multiply anything by 2. You don't even have a 'sum' command!
If you want effective help here it would be best to explain your problem much more clearly than you have so far done. What precisely is your test supposed to accomplish and in what way is it related to the matrix you called 'R'?
Fatima Al Marzoqi
2014년 7월 12일
카테고리
도움말 센터 및 File Exchange에서 Operating on Diagonal Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!