Borrar filtros
Borrar filtros

Code of Iterative method's test

1 visualización (últimos 30 días)
Fatima Al Marzoqi
Fatima Al Marzoqi el 12 de Jul. de 2014
Comentada: Roger Stafford el 12 de Jul. de 2014
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 comentarios
Jan
Jan el 12 de Jul. de 2014
Editada: Jan el 12 de Jul. de 2014
Which "test" do you mean? Please explain all required details. We cannot guess them.
Matt J
Matt J el 12 de Jul. de 2014
When you call the function with some sample input, do you get the output you expect? If so, what more is there to do?

Iniciar sesión para comentar.

Respuestas (2)

Roger Stafford
Roger Stafford el 12 de Jul. de 2014
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 comentarios
Fatima Al Marzoqi
Fatima Al Marzoqi el 12 de Jul. de 2014
yes that what I want .. but it doesn't work with my code !
check please , I attach my code
Roger Stafford
Roger Stafford el 12 de Jul. de 2014
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'?

Iniciar sesión para comentar.


Fatima Al Marzoqi
Fatima Al Marzoqi el 12 de Jul. de 2014
it is a loop that we apply for each row the on diagonal element must be greater than the rest elements
%Test
for i=1:4
for j=4:-1:1
if j~=i
S=sum(abs(R(i,j)));
end
end
if abs(R(i,i))<S
display ('Test Failed');
fprintf(fid,'Test Failed')
break
end
end

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by